Class LauncherExecutionRequestBuilder
java.lang.Object
org.junit.platform.launcher.core.LauncherExecutionRequestBuilder
@API(status=MAINTAINED,
since="6.0")
public final class LauncherExecutionRequestBuilder
extends Object
The
LauncherExecutionRequestBuilder provides a light-weight DSL for
generating a LauncherExecutionRequest.
Example
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectPackage;
import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.discoveryRequest;
import static org.junit.platform.launcher.core.LauncherExecutionRequestBuilder.executionRequest;
import org.junit.platform.engine.CancellationToken;
import org.junit.platform.launcher.LauncherDiscoveryRequest;
import org.junit.platform.launcher.LauncherExecutionRequest;
import org.junit.platform.launcher.TestExecutionListener;
TestExecutionListener listener = ...
CancellationToken cancellationToken = CancellationToken.create();
LauncherDiscoveryRequest discoveryRequest = discoveryRequest()
.selectors(selectPackage("org.example.user"))
.build();
LauncherExecutionRequest executionRequest = executionRequest(discoveryRequest)
.listeners(listener)
.cancellationToken(cancellationToken)
.build();- Since:
- 6.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build theLauncherExecutionRequestthat has been configured via this builder.cancellationToken(CancellationToken cancellationToken) Set the cancellation token for the request.executionRequest(LauncherDiscoveryRequest discoveryRequest) Create a newLauncherExecutionRequestBuilderfrom the suppliedLauncherDiscoveryRequest.executionRequest(TestPlan testPlan) Create a newLauncherExecutionRequestBuilderfrom the suppliedTestPlan.listeners(TestExecutionListener... listeners) Add all supplied execution listeners to the request.request(LauncherDiscoveryRequest discoveryRequest) Create a newLauncherExecutionRequestBuilderfrom the suppliedLauncherDiscoveryRequest.Create a newLauncherExecutionRequestBuilderfrom the suppliedTestPlan.
-
Method Details
-
request
Create a newLauncherExecutionRequestBuilderfrom the suppliedLauncherDiscoveryRequest.- Returns:
- a new builder
- See Also:
-
executionRequest
public static LauncherExecutionRequestBuilder executionRequest(LauncherDiscoveryRequest discoveryRequest) Create a newLauncherExecutionRequestBuilderfrom the suppliedLauncherDiscoveryRequest.This method is an alias for
request(LauncherDiscoveryRequest)and is intended to be used when statically imported — for example, via:import static org.junit.platform.launcher.core.LauncherExecutionRequestBuilder.executionRequest;- Returns:
- a new builder
- See Also:
-
request
Create a newLauncherExecutionRequestBuilderfrom the suppliedTestPlan.- Returns:
- a new builder
- See Also:
-
executionRequest
Create a newLauncherExecutionRequestBuilderfrom the suppliedTestPlan.This method is an alias for
request(TestPlan)and is intended to be used when statically imported — for example, via:import static org.junit.platform.launcher.core.LauncherExecutionRequestBuilder.executionRequest;- Returns:
- a new builder
- See Also:
-
listeners
Add all supplied execution listeners to the request.- Parameters:
listeners- theTestExecutionListenerto add; nevernull- Returns:
- this builder for method chaining
- See Also:
-
cancellationToken
Set the cancellation token for the request.- Parameters:
cancellationToken- theCancellationTokento use; nevernull.- Returns:
- this builder for method chaining
- See Also:
-
build
Build theLauncherExecutionRequestthat has been configured via this builder.
-