@API(status=STABLE, since="1.0") public final class LauncherDiscoveryRequestBuilder extends Object
LauncherDiscoveryRequestBuilder
provides a light-weight DSL for
generating a LauncherDiscoveryRequest
.
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();
DiscoverySelectors
,
ClassNameFilter
,
EngineFilter
,
TagFilter
Constructor and Description |
---|
LauncherDiscoveryRequestBuilder() |
Modifier and Type | Method and Description |
---|---|
LauncherDiscoveryRequest |
build()
Build the
LauncherDiscoveryRequest 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 supplied
filters to the request. |
static LauncherDiscoveryRequestBuilder |
request()
Create a new
LauncherDiscoveryRequestBuilder . |
LauncherDiscoveryRequestBuilder |
selectors(DiscoverySelector... selectors)
Add all of the supplied
selectors to the request. |
LauncherDiscoveryRequestBuilder |
selectors(List<? extends DiscoverySelector> selectors)
Add all of the supplied
selectors to the request. |
public static LauncherDiscoveryRequestBuilder request()
LauncherDiscoveryRequestBuilder
.public LauncherDiscoveryRequestBuilder selectors(DiscoverySelector... selectors)
selectors
to the request.selectors
- the DiscoverySelectors
to add; never null
public LauncherDiscoveryRequestBuilder selectors(List<? extends DiscoverySelector> selectors)
selectors
to the request.selectors
- the DiscoverySelectors
to add; never null
public LauncherDiscoveryRequestBuilder filters(Filter<?>... filters)
filters
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
competing exclude
EngineFilters
for the same discovery request since doing so will likely lead to
undesirable results (i.e., zero engines being active).
filters
- the Filter
s to add; never null
public LauncherDiscoveryRequestBuilder configurationParameter(String key, String value)
key
- the configuration parameter key under which to store the
value; never null
or blankvalue
- the value to storepublic LauncherDiscoveryRequestBuilder configurationParameters(Map<String,String> configurationParameters)
configurationParameters
- the map of configuration parameters to add;
never null
configurationParameter(String, String)
public LauncherDiscoveryRequest build()
LauncherDiscoveryRequest
that has been configured via
this builder.