eclipse web tools
platform project

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. Introduction

Is 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:

  • Critical and/or complex code should always have a unit test associated with it
  • Code that is found to contain an error must have a unit test created and successfully run as a requirement of closing the PR associated with the error.
  • All other code as time permits and common sense dictates

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.

  • JDepend for generating metrics from the WTP code.
  • JFunc for creating functional tests for the WTP code.

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".

For example:

Say the classes that you are testing are contained in project named

You would create a Java Project called

In the project "" 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 called:


Individual tests and test suites would reside in each of the corresponding packages. Tests to test the code in would be found in Likewise, tests to test the code in would be found in'. The higher level main test class "" would reside in the test project

3. References

JUnit has a plug-in that is bundled with Eclipse 2.0. It includes the following plug-ins:

  • org.junit
  • org.eclipse.jdt.junit
The main JUnit website has a wealth of information and additional QA tools.