Class LauncherDiscoveryRequestBuilder
- java.lang.Object
-
- org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
-
@API(status=STABLE, since="1.0") public final class LauncherDiscoveryRequestBuilder extends java.lang.ObjectTheLauncherDiscoveryRequestBuilderprovides 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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAMEProperty name used to set the default discovery listener that is added to all : "junit.platform.discovery.listener.default"
-
Constructor Summary
Constructors Constructor Description LauncherDiscoveryRequestBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LauncherDiscoveryRequestbuild()Build theLauncherDiscoveryRequestthat has been configured via this builder.LauncherDiscoveryRequestBuilderconfigurationParameter(java.lang.String key, java.lang.String value)Add the supplied configuration parameter to the request.LauncherDiscoveryRequestBuilderconfigurationParameters(java.util.Map<java.lang.String,java.lang.String> configurationParameters)Add all of the supplied configuration parameters to the request.LauncherDiscoveryRequestBuilderenableImplicitConfigurationParameters(boolean enabled)Configure whether implicit configuration parameters should be considered.LauncherDiscoveryRequestBuilderfilters(org.junit.platform.engine.Filter<?>... filters)Add all of the suppliedfiltersto the request.LauncherDiscoveryRequestBuilderlisteners(LauncherDiscoveryListener... listeners)Add all of the supplied discovery listeners to the request.static LauncherDiscoveryRequestBuilderrequest()Create a newLauncherDiscoveryRequestBuilder.LauncherDiscoveryRequestBuilderselectors(java.util.List<? extends org.junit.platform.engine.DiscoverySelector> selectors)Add all of the suppliedselectorsto the request.LauncherDiscoveryRequestBuilderselectors(org.junit.platform.engine.DiscoverySelector... selectors)Add all of the suppliedselectorsto the request.
-
-
-
Field Detail
-
DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAME
public static final java.lang.String DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAME
Property name used to set the default discovery listener that is added to all : "junit.platform.discovery.listener.default"Supported Values
Supported values are
"logging"and"abortOnFailure".If not specified, the default is
"logging".- See Also:
- Constant Field Values
-
-
Method Detail
-
request
public static LauncherDiscoveryRequestBuilder request()
Create a newLauncherDiscoveryRequestBuilder.- Returns:
- a new builder
-
selectors
public LauncherDiscoveryRequestBuilder selectors(org.junit.platform.engine.DiscoverySelector... selectors)
Add all of the suppliedselectorsto the request.- Parameters:
selectors- theDiscoverySelectorsto add; nevernull- Returns:
- this builder for method chaining
-
selectors
public LauncherDiscoveryRequestBuilder selectors(java.util.List<? extends org.junit.platform.engine.DiscoverySelector> selectors)
Add all of the suppliedselectorsto the request.- Parameters:
selectors- theDiscoverySelectorsto add; nevernull- Returns:
- this builder for method chaining
-
filters
public LauncherDiscoveryRequestBuilder filters(org.junit.platform.engine.Filter<?>... filters)
Add all of the suppliedfiltersto the request.The
filtersare 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
includeEngineFiltersor multiple competingexcludeEngineFiltersfor the same discovery request since doing so will likely lead to undesirable results (i.e., zero engines being active).- Parameters:
filters- theFilters to add; nevernull- Returns:
- this builder for method chaining
-
configurationParameter
public LauncherDiscoveryRequestBuilder configurationParameter(java.lang.String key, java.lang.String value)
Add the supplied configuration parameter to the request.- Parameters:
key- the configuration parameter key under which to store the value; nevernullor blankvalue- the value to store- Returns:
- this builder for method chaining
-
configurationParameters
public LauncherDiscoveryRequestBuilder configurationParameters(java.util.Map<java.lang.String,java.lang.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)
-
listeners
@API(status=EXPERIMENTAL, since="1.6") public LauncherDiscoveryRequestBuilder listeners(LauncherDiscoveryListener... listeners)Add all of the supplied discovery listeners to the request.In addition to the listeners registered using this method, this builder will add a default listener to this request that can be specified using the "junit.platform.discovery.listener.default" configuration parameter.
- Parameters:
listeners- theLauncherDiscoveryListenersto add; nevernull- Returns:
- this builder for method chaining
- See Also:
LauncherDiscoveryListener,LauncherDiscoveryListeners,DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAME
-
enableImplicitConfigurationParameters
@API(status=EXPERIMENTAL, since="1.7") public LauncherDiscoveryRequestBuilder enableImplicitConfigurationParameters(boolean enabled)Configure whether implicit configuration parameters should be considered.By default, in addition to those parameters that are passed explicitly to this builder, configuration parameters are read from system properties and from the
junit-platform.propertiesclasspath resource. Passingfalseto this method, disables the latter two sources so that only explicit configuration parameters are taken into account.
-
build
public LauncherDiscoveryRequest build()
Build theLauncherDiscoveryRequestthat has been configured via this builder.
-
-