Overview

The 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.

JUnitService.java
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.

  • No labels