Class EngineTestKit
EngineTestKit provides support for discovering and executing tests
for a given TestEngine and provides convenient access to the results.
For discovery, EngineDiscoveryResults provides access to
the TestDescriptor of the engine and any DiscoveryIssues that were encountered.
For execution, EngineExecutionResults provides a fluent
API to verify the expected results.
- Since:
- 1.4
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic EngineDiscoveryResultsdiscover(String engineId, LauncherDiscoveryRequest discoveryRequest) Discover tests for the givenLauncherDiscoveryRequestusing theTestEnginewith the supplied ID.static EngineDiscoveryResultsdiscover(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest) Discover tests for the givenLauncherDiscoveryRequestusing the suppliedTestEngine.static EngineTestKit.BuilderCreate an executionEngineTestKit.Builderfor theTestEnginewith the supplied ID.static EngineTestKit.Builderengine(TestEngine testEngine) Create an executionEngineTestKit.Builderfor the suppliedTestEngine.static EngineExecutionResultsexecute(String engineId, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequestusing theTestEnginewith the supplied ID.static EngineExecutionResultsexecute(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequestusing the suppliedTestEngine.
-
Method Details
-
engine
Create an executionEngineTestKit.Builderfor theTestEnginewith the supplied ID.The
TestEnginewill be loaded via Java'sServiceLoadermechanism, 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 theTestEngineto use; must not benullor blank- Returns:
- the engine execution
Builder - Throws:
PreconditionViolationException- if the supplied ID isnullor blank, or if theTestEnginewith the supplied ID cannot be loaded- See Also:
-
engine
Create an executionEngineTestKit.Builderfor the suppliedTestEngine.Example Usage
EngineTestKit .engine(new MyTestEngine()) .selectors(selectClass(MyTests.class)) .execute() .testEvents() .assertStatistics(stats -> stats.started(2).finished(2));- Parameters:
testEngine- theTestEngineto use; must not benull- Returns:
- the engine execution
Builder - Throws:
PreconditionViolationException- if theTestEngineisnull- See Also:
-
discover
@API(status=EXPERIMENTAL, since="6.0") public static EngineDiscoveryResults discover(String engineId, LauncherDiscoveryRequest discoveryRequest) Discover tests for the givenLauncherDiscoveryRequestusing theTestEnginewith the supplied ID.The
TestEnginewill be loaded via Java'sServiceLoadermechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.LauncherDiscoveryRequestBuilderprovides 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 theTestEngineto use; must not benullor blankdiscoveryRequest- theLauncherDiscoveryRequestto use- Returns:
- the results of the discovery
- Throws:
PreconditionViolationException- for invalid arguments or if theTestEnginewith the supplied ID cannot be loaded- Since:
- 1.13
- See Also:
-
discover
@API(status=EXPERIMENTAL, since="6.0") public static EngineDiscoveryResults discover(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest) Discover tests for the givenLauncherDiscoveryRequestusing the suppliedTestEngine.LauncherDiscoveryRequestBuilderprovides 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- theTestEngineto use; must not benulldiscoveryRequest- theEngineDiscoveryResultsto use; must not benull- Returns:
- the recorded
EngineExecutionResults - Throws:
PreconditionViolationException- for invalid arguments- Since:
- 1.13
- See Also:
-
execute
public static EngineExecutionResults execute(String engineId, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequestusing theTestEnginewith the supplied ID.The
TestEnginewill be loaded via Java'sServiceLoadermechanism, analogous to the manner in which test engines are loaded in the JUnit Platform Launcher API.LauncherDiscoveryRequestBuilderprovides 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 theTestEngineto use; must not benullor blankdiscoveryRequest- theLauncherDiscoveryRequestto use- Returns:
- the results of the execution
- Throws:
PreconditionViolationException- for invalid arguments or if theTestEnginewith the supplied ID cannot be loaded- Since:
- 1.7
- See Also:
-
execute
public static EngineExecutionResults execute(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest) Execute tests for the givenLauncherDiscoveryRequestusing the suppliedTestEngine.LauncherDiscoveryRequestBuilderprovides 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- theTestEngineto use; must not benulldiscoveryRequest- theLauncherDiscoveryRequestto use; must not benull- Returns:
- the recorded
EngineExecutionResults - Throws:
PreconditionViolationException- for invalid arguments- Since:
- 1.7
- See Also:
-