About Rudiger Herrmann
Among my fellow team members I was known for notoriously forgetting to maintain the (JUnit) test suite. I just can’t get this extra step of manually adding a test to a suite into my fingers. Fortunately there are continuous integration servers that collect tests by a naming pattern. If one of the orphan tests I introduced fails, it stands out there.
To make up for that I created an (almost) maintenance-free test runner. While there is such thing already for plain JUnit tests, I couldn’t find something similar for OSGi tests.
When having multiple bundles you usually have a master test suite that aggregates all per-bundle test suites. To use the BundleTestSuite, just replace your master test suite like this:
@RunWith( BundleTestSuite.class )@TestBundles( { "org.example.bundle1", "org.example.bundle2" } )public class MasterTestSuite {} The RunWith annotation tells JUnit to use the BundleTestSuite test runner. This test runner then evaluates the TestBundles annotation and executes the tests from all bundles whose symbolic names are listed there. If you create a new bundle, add its name to the TestBundles list and all test that it (or its fragments) contains will be picked up. A test class is currently identified by its name. All classes whose name ends with ‘Test’ are considered test classes.
Source : http://www.javacodegeeks.com/2013/07/an-automated-osgi-test-runner.html