Class EngineTestKit
- java.lang.Object
-
- org.junit.platform.testkit.engine.EngineTestKit
-
@API(status=MAINTAINED, since="1.7") public final class EngineTestKit extends java.lang.ObjectEngineTestKitprovides support for discovering and executing tests for a givenTestEngineand provides convenient access to the results.For discovery,
EngineDiscoveryResultsprovides access to theTestDescriptorof the engine and anyDiscoveryIssuesthat were encountered.For execution,
EngineExecutionResultsprovides a fluent API to verify the expected results.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEngineTestKit.BuilderTestEngineexecution builder.
-
Constructor Summary
Constructors Modifier Constructor Description privateEngineTestKit()
-
Method Summary
-
-
-
Method Detail
-
engine
public static EngineTestKit.Builder engine(java.lang.String engineId)
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:
org.junit.platform.commons.PreconditionViolationException- if the supplied ID isnullor blank, or if theTestEnginewith the supplied ID cannot be loaded- See Also:
engine(TestEngine),execute(String, LauncherDiscoveryRequest),execute(TestEngine, LauncherDiscoveryRequest)
-
engine
public static EngineTestKit.Builder engine(TestEngine testEngine)
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:
org.junit.platform.commons.PreconditionViolationException- if theTestEngineisnull- See Also:
engine(String),execute(String, LauncherDiscoveryRequest),execute(TestEngine, LauncherDiscoveryRequest)
-
discover
@API(status=MAINTAINED, since="1.13.3") public static EngineDiscoveryResults discover(java.lang.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:
org.junit.platform.commons.PreconditionViolationException- for invalid arguments or if theTestEnginewith the supplied ID cannot be loaded- Since:
- 1.13
- See Also:
discover(TestEngine, LauncherDiscoveryRequest),engine(String),engine(TestEngine)
-
discover
@API(status=MAINTAINED, since="1.13.3") 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:
org.junit.platform.commons.PreconditionViolationException- for invalid arguments- Since:
- 1.13
- See Also:
discover(String, LauncherDiscoveryRequest),engine(String),engine(TestEngine)
-
execute
@Deprecated @API(status=DEPRECATED, since="1.7") public static EngineExecutionResults execute(java.lang.String engineId, EngineDiscoveryRequest discoveryRequest)Deprecated.Please useexecute(String, LauncherDiscoveryRequest)instead.Execute tests for the givenEngineDiscoveryRequestusing 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.Note that
LauncherDiscoveryRequestfrom thejunit-platform-launchermodule is a subtype ofEngineDiscoveryRequest. It is therefore quite convenient to make use of the DSL provided inLauncherDiscoveryRequestBuilderto 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 theTestEngineto use; must not benullor blankdiscoveryRequest- theEngineDiscoveryRequestto use- Returns:
- the results of the execution
- Throws:
org.junit.platform.commons.PreconditionViolationException- for invalid arguments or if theTestEnginewith the supplied ID cannot be loaded- See Also:
execute(String, LauncherDiscoveryRequest),engine(String),engine(TestEngine)
-
execute
public static EngineExecutionResults execute(java.lang.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:
org.junit.platform.commons.PreconditionViolationException- for invalid arguments or if theTestEnginewith the supplied ID cannot be loaded- Since:
- 1.7
- See Also:
execute(TestEngine, LauncherDiscoveryRequest),engine(String),engine(TestEngine)
-
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 givenEngineDiscoveryRequestusing the suppliedTestEngine.Note that
LauncherDiscoveryRequestfrom thejunit-platform-launchermodule is a subtype ofEngineDiscoveryRequest. It is therefore quite convenient to make use of the DSL provided inLauncherDiscoveryRequestBuilderto 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- theEngineDiscoveryRequestto use; must not benull- Returns:
- the recorded
EngineExecutionResults - Throws:
org.junit.platform.commons.PreconditionViolationException- for invalid arguments- See Also:
execute(TestEngine, LauncherDiscoveryRequest),engine(String),engine(TestEngine)
-
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:
org.junit.platform.commons.PreconditionViolationException- for invalid arguments- Since:
- 1.7
- See Also:
execute(String, LauncherDiscoveryRequest),engine(String),engine(TestEngine)
-
executeDirectly
private static void executeDirectly(TestEngine testEngine, EngineDiscoveryRequest discoveryRequest, EngineExecutionListener listener)
-
executeUsingLauncherOrchestration
private static void executeUsingLauncherOrchestration(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest, EngineExecutionListener listener)
-
withRequestLevelStore
private static void withRequestLevelStore(java.util.function.Consumer<NamespacedHierarchicalStore<Namespace>> action)
-
newStore
private static NamespacedHierarchicalStore<Namespace> newStore(NamespacedHierarchicalStore<Namespace> parentStore)
-
discoverUsingOrchestrator
private static LauncherDiscoveryResult discoverUsingOrchestrator(TestEngine testEngine, LauncherDiscoveryRequest discoveryRequest)
-
loadTestEngine
private static TestEngine loadTestEngine(java.lang.String engineId)
-
-