[osgi-dev] Unit testing

Peter Kriens Peter.Kriens at aQute.biz
Thu Nov 9 04:40:13 EST 2006

You make it sound like the OSGi is a mighty beast like J2EE. Felix is
only about 250k and Knopflerfish is similar. Starting an OSGi
framework is very quickly in most cases and has less overhead than a

I agree  that unit testing should be just that. Making POJOs is a bit
harder in the beginning but you make much more useful components.
However, in the end you will have to run some tests in a full blown
OSGi context. I prefer to run these tests in a running framework
during developing. We have a tool for OSGi members that makes this
quite easy from within Eclipse or from ant and even a standalone UI.

Kind regards,

     Peter Kriens

DL> Our approach is to keep JUnit totally separate from OSGi, and I
DL> personally feel more comfortable with this.

DL> I see unit tests as just that: UNIT tests. They should remain much lower
DL> level and should be, IMHO, unrelated to the full-blown OSGi runtime
DL> environment. That does not exclude OSGi replacing JUnit, but I think
DL> it's overkill to require a complete OSGi runtime for simple unit tests.

DL> We just use a simple mock service manager to do this, and it works for
DL> us. The only thing I don't like is that we need to add in the
DL> dependencies by hand. Would be nice to have more integration with the
DL> pom.

DL> Now, if we're talking about integration testing, that's another matter.
DL> By definition, bundles need to work together. Ideally, the integration
DL> tests should also test for various possible runtime conditions, such as
DL> what happens when a given service is not availalbe, etc. In this case,
DL> there needs to be some kind of integration with OSGi.

DL> However, the title of the mail says "Unit testing" and, in summary,
DL> unless I hear some good reason to do otherwise, I strongly feel that
DL> unit testing should be kept as a separate concern from OSGi.

DL> Cheers,
DL> Dave

DL> On Wed, 2006-11-08 at 17:38 -0500, Alex Karasulu wrote:
>> Nikunj Mehta wrote:
>> > How do you combine unit testing with bundle development? Is there a nice 
>> > integration of JUnit and OSGI that is widely used for this?
>> > 
>> > I find it a particularly thorny issue since both JUnit and OSGI assume 
>> > complete control of the running process, class loading, object 
>> > instantiation, and threads.
>> This is a main concern of mine as well.  I've brought it up a couple 
>> times at the felix mailing list.
>> I think there are some ideas floating around about building more of an 
>> integration testing framework that can help test your service within the 
>> confines of OSGi.
>> Richard Hall had given me a few pointers on similar work over at 
>> Knoplerfish.  He also had some good ideas in the same general direction.
>> Perhaps others can chime in as well so we can shed more light on this 
>> this issue.  Testing is very important to me.  It's been one of the 
>> major stumbling blocks for me in terms of completely adopting OSGi.
>> Alex
>> _______________________________________________
>> OSGi Developer Mail List
>> osgi-dev at bundles.osgi.org
>> http://bundles.osgi.org/mailman/listinfo/osgi-dev

DL> _______________________________________________
DL> OSGi Developer Mail List
DL> osgi-dev at bundles.osgi.org
DL> http://bundles.osgi.org/mailman/listinfo/osgi-dev

Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599

More information about the osgi-dev mailing list