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.

  1. Create a new Java project called "topten.test"
  2. Open the properties view on topten.test, and under Java Build Path > Projects, choose "topten"
  3. Add the JUnit library to the classpath of topten.test
  4. Drag from the source folder of topten into the source folder of topten.test.
  5. 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:

  1. Open the Continuous Testing Properties for topten.
  2. Make sure that the "Run all tests in the selected project, package, or source folder." radio button is checked.
  3. Click on the "Search.." button.
  4. Select the project topten.test.
  5. Press OK.
  6. 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:

  1. Open the Continuous Testing Properties for topten.test.
  2. Turn on Informed Testing and Continuous Testing.
  3. Click on the "Edit..." button to change the launch associated with the project.
  4. Select the launch "Ct Launch for Project topten" from the list on the left hand side.
  5. Press OK.
  6. 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.