Package org.junit.platform.launcher.core
Class LauncherDiscoveryRequestBuilder
- java.lang.Object
-
- org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
-
@API(status=STABLE, since="1.0") public final class LauncherDiscoveryRequestBuilder extends Object
TheLauncherDiscoveryRequestBuilder
provides a light-weight DSL for generating aLauncherDiscoveryRequest
.Example
import static org.junit.platform.engine.discovery.DiscoverySelectors.*; import static org.junit.platform.engine.discovery.ClassNameFilter.*; import static org.junit.platform.launcher.EngineFilter.*; import static org.junit.platform.launcher.TagFilter.*; // ... LauncherDiscoveryRequestBuilder.request() .selectors( selectPackage("org.example.user"), selectClass("org.example.payment.PaymentTests"), selectClass(ShippingTests.class), selectMethod("org.example.order.OrderTests#test1"), selectMethod("org.example.order.OrderTests#test2()"), selectMethod("org.example.order.OrderTests#test3(java.lang.String)"), selectMethod("org.example.order.OrderTests", "test4"), selectMethod(OrderTests.class, "test5"), selectMethod(OrderTests.class, testMethod), selectClasspathRoots(Collections.singleton(new File("/my/local/path1"))), selectUniqueId("unique-id-1"), selectUniqueId("unique-id-2") ) .filters( includeEngines("junit-jupiter", "spek"), // excludeEngines("junit-vintage"), includeTags("fast"), // excludeTags("slow"), includeClassNamePatterns(".*Test[s]?") // includeClassNamePatterns("org\.example\.tests.*") ) .configurationParameter("key1", "value1") .configurationParameters(configParameterMap) .build();
- Since:
- 1.0
- See Also:
DiscoverySelectors
,ClassNameFilter
,EngineFilter
,TagFilter
-
-
Constructor Summary
Constructors Constructor Description LauncherDiscoveryRequestBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LauncherDiscoveryRequest
build()
Build theLauncherDiscoveryRequest
that has been configured via this builder.LauncherDiscoveryRequestBuilder
configurationParameter(String key, String value)
Add the supplied configuration parameter to the request.LauncherDiscoveryRequestBuilder
configurationParameters(Map<String,String> configurationParameters)
Add all of the supplied configuration parameters to the request.LauncherDiscoveryRequestBuilder
filters(Filter<?>... filters)
Add all of the suppliedfilters
to the request.static LauncherDiscoveryRequestBuilder
request()
Create a newLauncherDiscoveryRequestBuilder
.LauncherDiscoveryRequestBuilder
selectors(List<? extends DiscoverySelector> selectors)
Add all of the suppliedselectors
to the request.LauncherDiscoveryRequestBuilder
selectors(DiscoverySelector... selectors)
Add all of the suppliedselectors
to the request.
-
-
-
Method Detail
-
request
public static LauncherDiscoveryRequestBuilder request()
Create a newLauncherDiscoveryRequestBuilder
.- Returns:
- a new builder
-
selectors
public LauncherDiscoveryRequestBuilder selectors(DiscoverySelector... selectors)
Add all of the suppliedselectors
to the request.- Parameters:
selectors
- theDiscoverySelectors
to add; nevernull
- Returns:
- this builder for method chaining
-
selectors
public LauncherDiscoveryRequestBuilder selectors(List<? extends DiscoverySelector> selectors)
Add all of the suppliedselectors
to the request.- Parameters:
selectors
- theDiscoverySelectors
to add; nevernull
- Returns:
- this builder for method chaining
-
filters
public LauncherDiscoveryRequestBuilder filters(Filter<?>... filters)
Add all of the suppliedfilters
to the request.The
filters
are combined using AND semantics, i.e. all of them have to include a resource for it to end up in the test plan.Warning: be cautious when registering multiple competing
include
EngineFilters
or multiple competingexclude
EngineFilters
for the same discovery request since doing so will likely lead to undesirable results (i.e., zero engines being active).- Parameters:
filters
- theFilter
s to add; nevernull
- Returns:
- this builder for method chaining
-
configurationParameter
public LauncherDiscoveryRequestBuilder configurationParameter(String key, String value)
Add the supplied configuration parameter to the request.- Parameters:
key
- the configuration parameter key under which to store the value; nevernull
or blankvalue
- the value to store- Returns:
- this builder for method chaining
-
configurationParameters
public LauncherDiscoveryRequestBuilder configurationParameters(Map<String,String> configurationParameters)
Add all of the supplied configuration parameters to the request.- Parameters:
configurationParameters
- the map of configuration parameters to add; nevernull
- Returns:
- this builder for method chaining
- See Also:
configurationParameter(String, String)
-
build
public LauncherDiscoveryRequest build()
Build theLauncherDiscoveryRequest
that has been configured via this builder.
-
-