Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Virgo/Test
Virgo tests are implemented using JUnit and EasyMock. In addition, integration tests which require an OSGi environment use the Virgo test framework.
Contents
Virgo Test Framework
The Virgo Test Framework is maintained in its own git repository.
Test Runners
The test framework supports two test runners.
OsgiTestRunner
The OsgiTestRunner is for testing components that need a simple OSGi environment. It is invoked via the JUnit @RunWith class annotation, for example:
import org.junit.runner.RunWith; import org.eclipse.virgo.test.framework.OsgiTestRunner; @RunWith(OsgiTestRunner.class) public class EventLogIntegrationTests { ...
OsgiTestRunner launches Equinox, installs the project containing the testcase class as a bundle, starts the bundle, and then runs the testcase class from inside the bundle using a standard JUnit runner.
DmKernelTestRunner
The DmKernelTestRunner, which should probably be renamed to VirgoKernelTestRunner, is for testing components that need a Virgo kernel environment complete with kernel and user regions. It must be used in combination with suitable configuration to launch the kernel bundles and the bundle on which the kernel depends.
It is invoked via the JUnit @RunWith class annotation, for example:
import org.junit.runner.RunWith; import org.eclipse.virgo.test.framework.dmkernel.DmKernelTestRunner; @RunWith(DmKernelTestRunner.class) public abstract class AbstractKernelIntegrationTest { ...
The DmKernelTestRunner extends the function of the OsgiTestRunner to wait for the user region to start before running the testcase.
Annotations
Annotation | Type | Purpose | Default Value |
ConfigLocation | class | Specifies the location from which the test framework should load its configuration | META-INF/test.config.properties |
Utilities
The standard OSGi utility class FrameworkUtil is used to obtain the test bundle context as in the following example:
protected final BundleContext testBundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();