|eclipse web tools
Unit Test Guidelines
This project proposal is in the Proposal Phase and is posted here to solicit additional project participation and ways the project can be leveraged from the Eclipse membership-at-large. You are invited to comment on and/or join the project. Please send all feedback to the eclipse.webtools newsgroup or the wtp-proposal mailing list.
This document was inspired by the CDT Unit test document
1. IntroductionIs has been well proven that the time taken to write and run unit tests is recouped many times by reducing the time required to manually test, find and fix bugs. The WTP Team has adopted a policy of writing JUnit tests for WTP code in the following priority:
These tests will be integrated into our build process. Builds will not be marked as successful unless all unit tests, especially regression tests, run successfully. See the current Eclipse JUnit Help Pages for detailed instructions on creating and running JUnit tests within Eclipse.
In addition, the WTP Team is exploring the use of the following tools derived from JUnit. The following section on package naming conventions will hold true for tests using JDepend and/or JFunc and any other testing tools extending JUnit.
2. WTP JUnit Test Package Naming Conventions
In order to integrate the unit tests with our build process we have proposed the following structure and format be followed by all developers writing unit tests for WTP code. Suggestions for improvements are always welcome.
Create a JUnit project for each project that you are testing. The JUnit project name should be identical to the project being tested, with the additional postfix of ".tests".
Say the classes that you are testing are contained in project named org.eclipse.wtp.tools.foobar
You would create a Java Project called org.eclipse.wtp.tools.foobar.tests
In the project "org.eclipse.wtp.tools.foobar.tests" you would create tests in package structures that mirror the packages of the classes that they are designed to test.
Say that your project contained packages called:
You would create corresponding packages within the test project org.eclipse.wtp.tools.foobar.tests called:
Individual tests and test suites would reside in each of the corresponding packages. Tests to test the code in org.eclipse.wtp.tools.foobar.internal would be found in org.eclipse.wtp.tools.foobar.internal.tests. Likewise, tests to test the code in org.eclipse.wtp.tools.foobar.debug would be found in org.eclipse.wtp.tools.foobar.debug.tests'. The higher level main test class "AllTests.java" would reside in the test project org.eclipse.wtp.tools.foobar.common.tests
JUnit has a plug-in that is bundled with Eclipse 2.0. It includes the following plug-ins: