@API(status=MAINTAINED,
since="1.7")
public final class EngineTestKit
extends java.lang.Object
EngineTestKit provides support for executing a test plan for a given
TestEngine and then accessing the results via
a fluent API to verify the expected results.| Modifier and Type | Class and Description |
|---|---|
static class |
EngineTestKit.Builder
TestEngine execution builder. |
| Modifier | Constructor and Description |
|---|---|
private |
EngineTestKit() |
| Modifier and Type | Method and Description |
|---|---|
static EngineTestKit.Builder |
engine(java.lang.String engineId)
Create an execution
EngineTestKit.Builder for the TestEngine with the
supplied ID. |
static EngineTestKit.Builder |
engine(TestEngine testEngine)
Create an execution
EngineTestKit.Builder for the supplied TestEngine. |
static EngineExecutionResults |
execute(java.lang.String engineId,
EngineDiscoveryRequest discoveryRequest)
Deprecated.
Please use
execute(String, LauncherDiscoveryRequest)
instead. |
static EngineExecutionResults |
execute(java.lang.String engineId,
LauncherDiscoveryRequest discoveryRequest)
Execute tests for the given
LauncherDiscoveryRequest using the
TestEngine with the supplied ID. |
static EngineExecutionResults |
execute(TestEngine testEngine,
EngineDiscoveryRequest discoveryRequest)
Deprecated.
Please use
execute(TestEngine, LauncherDiscoveryRequest)
instead. |
static EngineExecutionResults |
execute(TestEngine testEngine,
LauncherDiscoveryRequest discoveryRequest)
Execute tests for the given
LauncherDiscoveryRequest using the
supplied TestEngine. |
private static void |
executeDirectly(TestEngine testEngine,
EngineDiscoveryRequest discoveryRequest,
EngineExecutionListener listener) |
private static void |
executeUsingLauncherOrchestration(TestEngine testEngine,
LauncherDiscoveryRequest discoveryRequest,
EngineExecutionListener listener) |
private static TestEngine |
loadTestEngine(java.lang.String engineId) |
public static EngineTestKit.Builder engine(java.lang.String engineId)
EngineTestKit.Builder for the TestEngine with the
supplied ID.
The TestEngine will be loaded via Java's ServiceLoader
mechanism, analogous to the manner in which test engines are loaded in
the JUnit Platform Launcher API.
EngineTestKit
.engine("junit-jupiter")
.selectors(selectClass(MyTests.class))
.execute()
.testEvents()
.assertStatistics(stats -> stats.started(2).finished(2));
engineId - the ID of the TestEngine to use; must not be
null or blankBuilderPreconditionViolationException - if the supplied ID is null
or blank, or if the TestEngine with the supplied ID
cannot be loadedengine(TestEngine),
execute(String, LauncherDiscoveryRequest),
execute(TestEngine, LauncherDiscoveryRequest)public static EngineTestKit.Builder engine(TestEngine testEngine)
EngineTestKit.Builder for the supplied TestEngine.
EngineTestKit
.engine(new MyTestEngine())
.selectors(selectClass(MyTests.class))
.execute()
.testEvents()
.assertStatistics(stats -> stats.started(2).finished(2));
testEngine - the TestEngine to use; must not be nullBuilderPreconditionViolationException - if the TestEngine is
nullengine(String),
execute(String, LauncherDiscoveryRequest),
execute(TestEngine, LauncherDiscoveryRequest)@Deprecated
@API(status=DEPRECATED,
since="1.7")
public static EngineExecutionResults execute(java.lang.String engineId,
EngineDiscoveryRequest discoveryRequest)
execute(String, LauncherDiscoveryRequest)
instead.EngineDiscoveryRequest using the
TestEngine with the supplied ID.
The TestEngine will be loaded via Java's ServiceLoader
mechanism, analogous to the manner in which test engines are loaded in
the JUnit Platform Launcher API.
Note that LauncherDiscoveryRequest
from the junit-platform-launcher module is a subtype of
EngineDiscoveryRequest. It is therefore quite convenient to make
use of the DSL provided in
LauncherDiscoveryRequestBuilder
to build an appropriate discovery request to supply to this method. As
an alternative, consider using engine(String) for a more fluent
API.
engineId - the ID of the TestEngine to use; must not be
null or blankdiscoveryRequest - the EngineDiscoveryRequest to usePreconditionViolationException - for invalid arguments or if the
TestEngine with the supplied ID cannot be loadedexecute(String, LauncherDiscoveryRequest),
engine(String),
engine(TestEngine)public static EngineExecutionResults execute(java.lang.String engineId, LauncherDiscoveryRequest discoveryRequest)
LauncherDiscoveryRequest using the
TestEngine with the supplied ID.
The TestEngine will be loaded via Java's ServiceLoader
mechanism, analogous to the manner in which test engines are loaded in
the JUnit Platform Launcher API.
LauncherDiscoveryRequestBuilder
provides a convenient way to build an appropriate discovery request to
supply to this method. As an alternative, consider using
engine(TestEngine) for a more fluent API.
engineId - the ID of the TestEngine to use; must not be
null or blankdiscoveryRequest - the LauncherDiscoveryRequest to usePreconditionViolationException - for invalid arguments or if the
TestEngine with the supplied ID cannot be loadedexecute(TestEngine, LauncherDiscoveryRequest),
engine(String),
engine(TestEngine)@Deprecated
@API(status=DEPRECATED,
since="1.7")
public static EngineExecutionResults execute(TestEngine testEngine,
EngineDiscoveryRequest discoveryRequest)
execute(TestEngine, LauncherDiscoveryRequest)
instead.EngineDiscoveryRequest using the
supplied TestEngine.
Note that LauncherDiscoveryRequest
from the junit-platform-launcher module is a subtype of
EngineDiscoveryRequest. It is therefore quite convenient to make
use of the DSL provided in
LauncherDiscoveryRequestBuilder
to build an appropriate discovery request to supply to this method. As
an alternative, consider using engine(TestEngine) for a more fluent
API.
testEngine - the TestEngine to use; must not be nulldiscoveryRequest - the EngineDiscoveryRequest to use; must
not be nullEngineExecutionResultsPreconditionViolationException - for invalid argumentsexecute(TestEngine, LauncherDiscoveryRequest),
engine(String),
engine(TestEngine)public static EngineExecutionResults execute(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest)
LauncherDiscoveryRequest using the
supplied TestEngine.
LauncherDiscoveryRequestBuilder
provides a convenient way to build an appropriate discovery request to
supply to this method. As an alternative, consider using
engine(TestEngine) for a more fluent API.
testEngine - the TestEngine to use; must not be nulldiscoveryRequest - the LauncherDiscoveryRequest to use; must
not be nullEngineExecutionResultsPreconditionViolationException - for invalid argumentsexecute(String, LauncherDiscoveryRequest),
engine(String),
engine(TestEngine)private static void executeDirectly(TestEngine testEngine, EngineDiscoveryRequest discoveryRequest, EngineExecutionListener listener)
private static void executeUsingLauncherOrchestration(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest, EngineExecutionListener listener)
private static TestEngine loadTestEngine(java.lang.String engineId)