OSGi Test Runner
OSGi Test Runner
The test runner bundle picks up tests and executes them. If you want to see the module in practice instead of reading its documentation, go through the chapters of the Everit Cookbook.
The module picks up every OSGi service having the following service properties defined:
The tests have to be provided as OSGi services, and the JUnit annotations are required to be placed into the implementation of the OSGi service.
In ordinary JUnit based solutions, the programmer has to provide the class name so that the JUnit technology can instantiate the class. By using this bundle, the programmer instantiates the JUnit test class with any technology. E.g.: Declarative Services, Blueprint or Everit Component Model
The following System or Framework properties make it easier to integrate the testrunner with build tools.
The following environment variables make it easier to integrate the testrunner with build tools.
In case the "Stop after tests" setting is set to true, the test runner will shut down the JVM after all tests are executed. However, it is not trivial how much the test runner should wait for. Shutdown Blocker OSGi services can be registered to tell the test runner to wait for more tests to be executed. The runner will shut down the JVM only if all blockers are in non-blocking state.
There are two Shutdown Blockers by default:
The TestCase shutdown blocker does not allow the test runner to shut down the JVM until all test classes that are specified with eosgi.testClass bundle capabilities are executed. An example:
Provide-Capability: eosgi.testClass;eosgi.testClass=foo.bar.MyTestClass;instanceCount=1
The executionCount attribute tells the blocker, how many times the test class should be executed. There might be cases when the same test class is registered multiple times with different configuration as OSGi services. The value of the instanceCount attribute is summarized so if multiple bundles contain the same capability, their values are summarized, even if the amount is a negative number.
It is hard to specify the bundle capability manually always. Therefore, the programmer can use the @EOSGiTestClass annotation on the test class to specify the capability. E.g.:
@EOSGiTestClass public class MyTestClass { @Test public void myTestMethod() { } }
The uses the testrunner bundle to run the written tests as a part of the build lifecycle. Test runner 5.x is supported from the version 4.1.0 of .