Home > OSGi > TestNG for OSGi Bundles

TestNG for OSGi Bundles

Problem: We need to test bundles deployed in OSGi.

Solution: Bundle test classes as xyz_tests.jar file. Convert this into bundle and deploy along with main bundle code.
In test bundle activator, programmatic way call TestNG as shown in http://testng.org/doc/documentation-main.html

TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
testng.setTestClasses(new Class[] { Run2.class });
testng.addListener(tla);
testng.run();

TestNG opens in its own JVM. Due to this it is not recognizing test classes. We can build OSGi classpath with the help of bundle context. But we dont have option to pass classpath to TestNG programitically. Even though we can pass, it uses jar files in path, But not the bundles.

Conclusion: We can’t use TestNG inside OSGi. Please let me know your experience.

-o-

Advertisement
Categories: OSGi Tags: , ,
  1. Mariana
    July 28, 2010 at 1:32 pm | #1

    Hi, have you ever used the junit4osgi ? I´m learning about it now, and looks very interesting. It has a felix-command so u can call tests suite inside your bundles.

    If you wanna try this: http://felix.apache.org/site/apache-felix-ipojo-junit4osgi-tutorial.html

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.