I've recently been working on a bndtools testing framework based on some Pax 
Exam envy. The result is _Launchpad_. It is a builder for a framework setup 
using all the information from a bnd workspace and its projects. For each test 
method you can then execute your tests without having to generate a test 
bundle. Due to some deep class loading magic, the class space of the test code 
(for example JUnit) is properly exported via the framework. Although there are 
some pitfalls, sharing the classes this way works quite well.

Launchpad also contains an injector that you can use to inject services and 
some key OSGi objects like BundleContext in your test object. A large number of 
utility methods on Launchpad provide conveniences for testing. For example, you 
can also hide services with one call.

Launchpad is agnostic of a testing framework. It has been tested with JUnit but 
TestNG or other frameworks should be no problem.

This is all documented: 
https://bnd.bndtools.org/chapters/315-launchpad-testing.html

This is an ambitious test environment. There is now experience at one of my 
customers but it clearly needs to go to a learning period. Almost all of what 
is documented is in 4.2.0 which is just released, if you want the absolute 
latest get the 4.3.0 snapshot. 

Launchpad is developed for the bnd Workspace model. I think it can be adapted 
to the Maven model with the bndrun files since this mimics a Workspace beneath 
the covers. However, that might require some work and surely some 
documentation. Volunteers welcome.

Let me know if this is useful and file issues on 
https://github.com/bndtools/bnd/issues when there are issues or really good 
ideas.

Kind regards,

        Peter Kriens
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to