Interface Launcher
-
@API(status=STABLE, since="1.0") public interface Launcher
TheLauncher
API is the main entry point for client code that wishes to discover and execute tests using one or more test engines.Implementations of this interface are responsible for determining the set of test engines to delegate to at runtime and for ensuring that each test engine has an ID that is unique among the registered test engines. For example, the default implementation returned by
LauncherFactory.create()
dynamically discovers test engines via Java'sServiceLoader
mechanism.Test discovery and execution require a
LauncherDiscoveryRequest
that is passed to all registered engines. Each engine decides which tests it can discover and execute according to the supplied request.Prior to executing tests, clients of this interface should register one or more
TestExecutionListener
instances in order to get feedback about the progress and results of test execution. Listeners will be notified of events in the order in which they were registered. The default implementation returned byLauncherFactory.create()
dynamically discovers test execution listeners via Java'sServiceLoader
mechanism.- Since:
- 1.0
- See Also:
LauncherDiscoveryRequest
,TestPlan
,TestExecutionListener
,LauncherFactory
,TestEngine
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TestPlan
discover(LauncherDiscoveryRequest launcherDiscoveryRequest)
Discover tests and build aTestPlan
according to the suppliedLauncherDiscoveryRequest
by querying all registered engines and collecting their results.void
execute(LauncherDiscoveryRequest launcherDiscoveryRequest, TestExecutionListener... listeners)
Execute aTestPlan
which is built according to the suppliedLauncherDiscoveryRequest
by querying all registered engines and collecting their results, and notify registered listeners about the progress and results of the execution.void
registerTestExecutionListeners(TestExecutionListener... listeners)
Register one or more listeners for test execution.
-
-
-
Method Detail
-
registerTestExecutionListeners
void registerTestExecutionListeners(TestExecutionListener... listeners)
Register one or more listeners for test execution.- Parameters:
listeners
- the listeners to be notified of test execution events; nevernull
or empty
-
discover
TestPlan discover(LauncherDiscoveryRequest launcherDiscoveryRequest)
Discover tests and build aTestPlan
according to the suppliedLauncherDiscoveryRequest
by querying all registered engines and collecting their results.- Parameters:
launcherDiscoveryRequest
- the launcher discovery request; nevernull
- Returns:
- a
TestPlan
that contains all resolved identifiers from all registered engines - API Note:
- This method should only be called to generate a preview of the
test tree when executing tests is not desired. First calling this method
to get access to the
TestPlan
and thenexecute(org.junit.platform.launcher.LauncherDiscoveryRequest, org.junit.platform.launcher.TestExecutionListener...)
causes test discovery to be executed twice which may result in a significant performance degradation. Instead,execute(org.junit.platform.launcher.LauncherDiscoveryRequest, org.junit.platform.launcher.TestExecutionListener...)
should be called directly and aTestExecutionListener
that overridesTestExecutionListener.testPlanExecutionStarted(TestPlan)
should be registered to get access to the test tree, for example to render it in an IDE.
-
execute
void execute(LauncherDiscoveryRequest launcherDiscoveryRequest, TestExecutionListener... listeners)
Execute aTestPlan
which is built according to the suppliedLauncherDiscoveryRequest
by querying all registered engines and collecting their results, and notify registered listeners about the progress and results of the execution.Supplied test execution listeners are registered in addition to already registered listeners but only for the supplied launcher discovery request.
- Parameters:
launcherDiscoveryRequest
- the launcher discovery request; nevernull
listeners
- additional test execution listeners; nevernull
- API Note:
- In order to get access to the test tree, for example to render
it in an IDE, register a
TestExecutionListener
that overridesTestExecutionListener.testPlanExecutionStarted(TestPlan)
instead of callingdiscover(org.junit.platform.launcher.LauncherDiscoveryRequest)
first.
-
-