Interface Launcher
Launcher 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's ServiceLoader 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 by LauncherFactory.create()
dynamically discovers test execution listeners via Java's
ServiceLoader mechanism.
- Since:
- 1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondiscover(LauncherDiscoveryRequest launcherDiscoveryRequest) Discover tests and build aTestPlanaccording to the suppliedLauncherDiscoveryRequestby querying all registered engines and collecting their results.default voidexecute(LauncherDiscoveryRequest launcherDiscoveryRequest, TestExecutionListener... listeners) Deprecated.voidexecute(LauncherExecutionRequest launcherExecutionRequest) Execute tests according to the suppliedLauncherExecutionRequestregistered listeners about the progress and results of the execution.default voidexecute(TestPlan testPlan, TestExecutionListener... listeners) Deprecated.Please useexecute(LauncherExecutionRequest)instead.voidregisterLauncherDiscoveryListeners(LauncherDiscoveryListener... listeners) Register one or more listeners for test discovery.voidregisterTestExecutionListeners(TestExecutionListener... listeners) Register one or more listeners for test execution.
-
Method Details
-
registerLauncherDiscoveryListeners
@API(status=STABLE, since="1.10") void registerLauncherDiscoveryListeners(LauncherDiscoveryListener... listeners) Register one or more listeners for test discovery.- Parameters:
listeners- the listeners to be notified of test discovery events; nevernullor empty
-
registerTestExecutionListeners
Register one or more listeners for test execution.- Parameters:
listeners- the listeners to be notified of test execution events; nevernullor empty
-
discover
Discover tests and build aTestPlanaccording to the suppliedLauncherDiscoveryRequestby querying all registered engines and collecting their results.- Parameters:
launcherDiscoveryRequest- the launcher discovery request; nevernull- Returns:
- an unmodifiable
TestPlanthat contains all resolved identifiers from all registered engines - API Note:
- This method may be called to generate a preview of the test
tree. The resulting
TestPlanis unmodifiable and may be passed toexecute(TestPlan, TestExecutionListener...)for execution at most once.
-
execute
@Deprecated @API(status=DEPRECATED, since="6.0") default void execute(LauncherDiscoveryRequest launcherDiscoveryRequest, TestExecutionListener... listeners) Deprecated.Please useexecute(LauncherExecutionRequest)instead.Execute aTestPlanwhich is built according to the suppliedLauncherDiscoveryRequestby 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; nevernulllisteners- additional test execution listeners; nevernull- API Note:
- Calling this method will cause test discovery to be executed for
all registered engines. If the same
LauncherDiscoveryRequestwas previously passed todiscover(LauncherDiscoveryRequest), you should instead callexecute(TestPlan, TestExecutionListener...)and pass the already acquiredTestPlanto avoid the potential performance degradation (e.g., classpath scanning) of running test discovery twice.
-
execute
@Deprecated @API(status=DEPRECATED, since="6.0") default void execute(TestPlan testPlan, TestExecutionListener... listeners) Deprecated.Please useexecute(LauncherExecutionRequest)instead.Execute the suppliedTestPlanand 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 execution of the supplied test plan.
- Parameters:
testPlan- the test plan to execute; nevernulllisteners- additional test execution listeners; nevernull- Since:
- 1.4
- API Note:
- The supplied
TestPlanmust not have been executed previously.
-
execute
@API(status=MAINTAINED, since="6.0") void execute(LauncherExecutionRequest launcherExecutionRequest) Execute tests according to the suppliedLauncherExecutionRequestregistered listeners about the progress and results of the execution.Test execution listeners supplied as part of the request are registered in addition to already registered listeners but only for the supplied execution request.
- Parameters:
launcherExecutionRequest- the launcher execution request; nevernull- Since:
- 6.0
- API Note:
- If the execution request contains a
TestPlanrather than aLauncherDiscoveryRequest, it must not have been executed previously.If the execution request contains a
LauncherDiscoveryRequest, calling this method will cause test discovery to be executed for all registered engines. If the sameLauncherDiscoveryRequestwas previously passed todiscover(LauncherDiscoveryRequest), you should instead provide the resultingTestPlanas part of the supplied execution request to avoid the potential performance degradation (e.g., classpath scanning) of running test discovery twice.
-
execute(LauncherExecutionRequest)instead.