Multiple Projects
Each project in Eclipse that has continuous testing enabled can have
only one associated test launch configuration. However, a project can
reference tests defined in a different project, and two or more
projects can share the same launch configuration.
To see why this might be desirable, consider that currently our topten
project references the junit libraries. While this is convenient for
our testing, it pollutes the classpath of our library: we don't want
to force our clients to have JUnit installed. So, it makes sense to
split the tests into their own project.
- Create a new Java project called "topten.test"
- Open the properties view on topten.test, and under Java Build Path
> Projects, choose "topten"
- Add the JUnit library to the classpath of topten.test
- Drag TopTenTest.java from the source folder of topten into the
source folder of topten.test.
- Remove the JUnit library from the classpath of topten.
While you follow the above steps, you may occasionally see errors in
the Progress View from continuous testing trying to run tests that
suddenly are no longer there, but these errors should resolve themselves.
We now need to adjust the continuous
testing properties of the two new projects.
First, topten's tests are no longer in the project itself, but in
topten.test:
- Open the Continuous Testing Properties for topten.
- Make sure that the "Run all tests in the selected project, package,
or source folder." radio button is checked.
- Click on the "Search.." button.
- Select the project topten.test.
- Press OK.
- Press OK to exit the property page.
Second, we want to be sure that any changes made to the tests in
topten.test trigger a test re-run:
- Open the Continuous Testing Properties for topten.test.
- Turn on Informed Testing and Continuous Testing.
- Click on the "Edit..." button to change the launch associated with the project.
- Select the launch "Ct Launch for Project topten" from the list on the
left hand side.
- Press OK.
- Press OK to exit the property page.
Making both projects point to the same configuration allows them to
share prioritization and filtering data, and it makes sure that continuous testing
handles the markers for the launch configuration correctly, for
example, not creating two markers for the same test failure, even if the
test was run on behalf of two different projects. Try introducing
test failures in both topten and topten.test to get comfortable with
the features.