Java – Run Junit-Tests from several projects conveniently fast in Eclipse

anteclipseeclipse-3.5javajunit

Is there a way to run JUnit-Tests from several projects conveniently fast in Eclipse?

The JUnit-Runner lets you define a package or a folder where from all contained tests are executed.

Is there a way to do this with tests from several projects inside Eclipse?
Preferably it should be via the Junit-Runner. If there is some way to have it fast via an Ant-job (so not depend on a complete build with ant before), that would be also nice.

Best Answer

It’s actually quite easy to perform JUnit tests across multiple projects from within Eclipse. Have a look at Classpath Suite. It’s not with the standard JUnit runner, but you did not mention where that requirement came from, so I’m not sure whether this will affect you.

All the usage information is on that page, but to summarize:

  1. Create an Eclipse project depending on all the projects you want to test.
  2. Write a simple test suite including everything:

    @RunWith(ClasspathSuite.class)  
    public class MySuite {}