Run tests in different packages and linked sources with JUnit TestSuite

In a project that I’m working on we’re using linked sources and we have multiple sub-packages with JUnit tests. We ran into some issues with running the test. Thankfully, although the eclipse wizards wouldn’t help us create a test suite that would run all the tests it was trivial to write the suite by hand.

It can look like this:

This will allow you to test any class that you import no matter what package it is in. To run this in eclipse you just right click the AllTests class and run it as JUnit test. It will then run all the tests you define in @SuiteClasses.

This will work with linked sources as well, I use it all the time.