Apache Felix Sigil JUnitPage added by David SavageOverviewThe Sigil JUnit plugin is an OSGi bundle that when started in an OSGi enabled JVM watches for other bundles that contain JUnit TestCase classes in the framework. The main access point to the plugin is the org.cauldron.sigil.junit.server.JUnitService.
package org.cauldron.sigil.junit.server;
import java.util.Set;
import org.osgi.framework.BundleContext;
import junit.framework.TestSuite;
/**
*
*/
public interface JUnitService {
/**
* Returns the names of all tests currently installed in the OSGi runtime
*/
Set<String> getTests();
/**
* Create a new instance of the specified test. Equivalent to calling createTest(test, null);
*/
TestSuite createTest(String test);
/**
* Create a new instance of the specified test passing the specified bundle context to the test classes.
* If ctx is null the callers BundleContext is passed to the test.
*/
TestSuite createTest(String test, BundleContext ctx);
}
When a test is created the JUnitService introspects the test class and looks for a method public void setBundleContext(BundleContext ctx); if one is found then the BundleContext is injected into the test class before being returned to the caller. CLIFor convenience we provide a simple newton command line interface to the JUnit plugin in the bundle org.cauldron.sigil.junit.cli. This allows the user to find and run tests currently installed in the container. examples:
junit
org.cauldron.sigil.junit.example.Test1
org.cauldron.sigil.junit.example.Test10
org.cauldron.sigil.junit.example.Test2
org.cauldron.sigil.junit.example.Test3
org.cauldron.sigil.junit.example.Test4
org.cauldron.sigil.junit.example.Test5
org.cauldron.sigil.junit.example.Test6
org.cauldron.sigil.junit.example.Test7
org.cauldron.sigil.junit.example.Test8
org.cauldron.sigil.junit.example.Test9
> junit org.cauldron.sigil.junit.example.Test1
Start testSuccess(org.cauldron.sigil.junit.example.Test1)
End testSuccess(org.cauldron.sigil.junit.example.Test1)
Start testFail(org.cauldron.sigil.junit.example.Test1)
Failure testFail(org.cauldron.sigil.junit.example.Test1): Failed
End testFail(org.cauldron.sigil.junit.example.Test1)
Ran 2 tests. 1 failures 0 errors.
> junit -q org.cauldron.sigil.junit.example.Test1
Ran 2 tests. 1 failures 0 errors.
> junit -q *
Ran 20 tests. 10 failures 0 errors.
> junit -q -d /tmp *
Writing results to /tmp
Ran 20 tests. 10 failures 0 errors.
Change Notification Preferences
View Online
|
Add Comment
|
- [CONF] Apache Felix > Apache Felix Sigil JUnit confluence
