Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

junitBundles() provisions JUnit and its dependencies as OSGi bundles to the test container.

 

Test Methods

Any method annotated with @Test will be run as a test within the OSGi framework launched by the test container.

...

@Before or @After methods and @Rule fields work as expected. The corresponding methods are executed within the test container. (@BeforeClass, @AfterClass and @ClassRule are not supported at the moment.)

Maven Considerations

 The The example test above uses mavenBundle(). This feature of pax-exam is provided by pax-url-aether. It finds OSGi bundles as Maven artifacts by opening up a separate session with the Aether repository manager. This all works fine so long as the versions of the bundles that you want are sitting in your local repository or some other configured repository. It won't resolve artifacts from the reactor. It's not hard to achieve this: put your pax-exam tests in an integration test module, and always  run mvn install .

If this is not practical or desirable for you (e.g. you use a continuous integration system that won't do mvn install easily, or if you really want to embed a pax-exam test into the project that builds the bundle it's testing), there are other alternativealternatives. One is Andreas Veithen's alta plugin. The explanation he wrote will put you on the road if you need to go here.

...