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.- Since:
- 1.4
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic EngineTestKit.Builder
Create an executionEngineTestKit.Builder
for theTestEngine
with the supplied ID.static EngineTestKit.Builder
engine
(TestEngine testEngine) Create an executionEngineTestKit.Builder
for the suppliedTestEngine
.static EngineExecutionResults
execute
(String engineId, EngineDiscoveryRequest discoveryRequest) Deprecated.static EngineExecutionResults
execute
(String engineId, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequest
using theTestEngine
with the supplied ID.static EngineExecutionResults
execute
(TestEngine testEngine, EngineDiscoveryRequest discoveryRequest) Deprecated.Please useexecute(TestEngine, LauncherDiscoveryRequest)
instead.static EngineExecutionResults
execute
(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequest
using the suppliedTestEngine
.
-
Method Details
-
engine
Create an executionEngineTestKit.Builder
for theTestEngine
with the supplied ID.The
TestEngine
will be loaded via Java'sServiceLoader
mechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.Example Usage
EngineTestKit .engine("junit-jupiter") .selectors(selectClass(MyTests.class)) .execute() .testEvents() .assertStatistics(stats -> stats.started(2).finished(2));
- Parameters:
engineId
- the ID of theTestEngine
to use; must not benull
or blank- Returns:
- the engine execution
Builder
- Throws:
PreconditionViolationException
- if the supplied ID isnull
or blank, or if theTestEngine
with the supplied ID cannot be loaded- See Also:
-
engine
Create an executionEngineTestKit.Builder
for the suppliedTestEngine
.Example Usage
EngineTestKit .engine(new MyTestEngine()) .selectors(selectClass(MyTests.class)) .execute() .testEvents() .assertStatistics(stats -> stats.started(2).finished(2));
- Parameters:
testEngine
- theTestEngine
to use; must not benull
- Returns:
- the engine execution
Builder
- Throws:
PreconditionViolationException
- if theTestEngine
isnull
- See Also:
-
execute
@Deprecated @API(status=DEPRECATED, since="1.7") public static EngineExecutionResults execute(String engineId, EngineDiscoveryRequest discoveryRequest) Deprecated.Please useexecute(String, LauncherDiscoveryRequest)
instead.Execute tests for the givenEngineDiscoveryRequest
using theTestEngine
with the supplied ID.The
TestEngine
will be loaded via Java'sServiceLoader
mechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.Note that
LauncherDiscoveryRequest
from thejunit-platform-launcher
module is a subtype ofEngineDiscoveryRequest
. It is therefore quite convenient to make use of the DSL provided inLauncherDiscoveryRequestBuilder
to build an appropriate discovery request to supply to this method. As an alternative, consider usingengine(String)
for a more fluent API.- Parameters:
engineId
- the ID of theTestEngine
to use; must not benull
or blankdiscoveryRequest
- theEngineDiscoveryRequest
to use- Returns:
- the results of the execution
- Throws:
PreconditionViolationException
- for invalid arguments or if theTestEngine
with the supplied ID cannot be loaded- See Also:
-
execute
public static EngineExecutionResults execute(String engineId, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequest
using theTestEngine
with the supplied ID.The
TestEngine
will be loaded via Java'sServiceLoader
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 usingengine(TestEngine)
for a more fluent API.- Parameters:
engineId
- the ID of theTestEngine
to use; must not benull
or blankdiscoveryRequest
- theLauncherDiscoveryRequest
to use- Returns:
- the results of the execution
- Throws:
PreconditionViolationException
- for invalid arguments or if theTestEngine
with the supplied ID cannot be loaded- Since:
- 1.7
- See Also:
-
execute
@Deprecated @API(status=DEPRECATED, since="1.7") public static EngineExecutionResults execute(TestEngine testEngine, EngineDiscoveryRequest discoveryRequest) Deprecated.Please useexecute(TestEngine, LauncherDiscoveryRequest)
instead.Execute tests for the givenEngineDiscoveryRequest
using the suppliedTestEngine
.Note that
LauncherDiscoveryRequest
from thejunit-platform-launcher
module is a subtype ofEngineDiscoveryRequest
. It is therefore quite convenient to make use of the DSL provided inLauncherDiscoveryRequestBuilder
to build an appropriate discovery request to supply to this method. As an alternative, consider usingengine(TestEngine)
for a more fluent API.- Parameters:
testEngine
- theTestEngine
to use; must not benull
discoveryRequest
- theEngineDiscoveryRequest
to use; must not benull
- Returns:
- the recorded
EngineExecutionResults
- Throws:
PreconditionViolationException
- for invalid arguments- See Also:
-
execute
public static EngineExecutionResults execute(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequest
using the suppliedTestEngine
.LauncherDiscoveryRequestBuilder
provides a convenient way to build an appropriate discovery request to supply to this method. As an alternative, consider usingengine(TestEngine)
for a more fluent API.- Parameters:
testEngine
- theTestEngine
to use; must not benull
discoveryRequest
- theLauncherDiscoveryRequest
to use; must not benull
- Returns:
- the recorded
EngineExecutionResults
- Throws:
PreconditionViolationException
- for invalid arguments- Since:
- 1.7
- See Also:
-
execute(String, LauncherDiscoveryRequest)
instead.