Class LauncherDiscoveryRequestBuilder
- java.lang.Object
-
- org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder
-
@API(status=STABLE, since="1.0") public final class LauncherDiscoveryRequestBuilder extends java.lang.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
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>
configurationParameters
static 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"private static java.lang.String
DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_VALUE
private java.util.List<DiscoveryFilter<?>>
discoveryFilters
private java.util.List<LauncherDiscoveryListener>
discoveryListeners
private java.util.List<EngineFilter>
engineFilters
private boolean
implicitConfigurationParametersEnabled
private ConfigurationParameters
parentConfigurationParameters
private java.util.List<PostDiscoveryFilter>
postDiscoveryFilters
private java.util.List<DiscoverySelector>
selectors
-
Constructor Summary
Constructors Constructor Description LauncherDiscoveryRequestBuilder()
Deprecated.Userequest()
-
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.private LauncherConfigurationParameters
buildLauncherConfigurationParameters()
LauncherDiscoveryRequestBuilder
configurationParameter(java.lang.String key, java.lang.String value)
Add the supplied configuration parameter to the request.LauncherDiscoveryRequestBuilder
configurationParameters(java.util.Map<java.lang.String,java.lang.String> configurationParameters)
Add all of the supplied configuration parameters to the request.LauncherDiscoveryRequestBuilder
enableImplicitConfigurationParameters(boolean enabled)
Configure whether implicit configuration parameters should be considered.LauncherDiscoveryRequestBuilder
filters(Filter<?>... filters)
Add all of the suppliedfilters
to the request.private LauncherDiscoveryListener
getDefaultLauncherDiscoveryListener(ConfigurationParameters configurationParameters)
private LauncherDiscoveryListener
getLauncherDiscoveryListener(ConfigurationParameters configurationParameters)
LauncherDiscoveryRequestBuilder
listeners(LauncherDiscoveryListener... listeners)
Add all of the supplied discovery listeners to the request.LauncherDiscoveryRequestBuilder
parentConfigurationParameters(ConfigurationParameters configurationParameters)
Set the parent configuration parameters to use for the request.static LauncherDiscoveryRequestBuilder
request()
Create a newLauncherDiscoveryRequestBuilder
.LauncherDiscoveryRequestBuilder
selectors(java.util.List<? extends DiscoverySelector> selectors)
Add all of the suppliedselectors
to the request.LauncherDiscoveryRequestBuilder
selectors(DiscoverySelector... selectors)
Add all of the suppliedselectors
to the request.private void
storeFilter(Filter<?> filter)
-
-
-
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 "abortOnFailure".
- See Also:
- Constant Field Values
-
DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_VALUE
private static final java.lang.String DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_VALUE
- See Also:
- Constant Field Values
-
selectors
private final java.util.List<DiscoverySelector> selectors
-
engineFilters
private final java.util.List<EngineFilter> engineFilters
-
discoveryFilters
private final java.util.List<DiscoveryFilter<?>> discoveryFilters
-
postDiscoveryFilters
private final java.util.List<PostDiscoveryFilter> postDiscoveryFilters
-
configurationParameters
private final java.util.Map<java.lang.String,java.lang.String> configurationParameters
-
discoveryListeners
private final java.util.List<LauncherDiscoveryListener> discoveryListeners
-
implicitConfigurationParametersEnabled
private boolean implicitConfigurationParametersEnabled
-
parentConfigurationParameters
private ConfigurationParameters parentConfigurationParameters
-
-
Constructor Detail
-
LauncherDiscoveryRequestBuilder
@API(status=DEPRECATED, since="1.8") @Deprecated public LauncherDiscoveryRequestBuilder()
Deprecated.Userequest()
-
-
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(java.util.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(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; nevernull
or 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)
-
parentConfigurationParameters
@API(status=EXPERIMENTAL, since="1.8") public LauncherDiscoveryRequestBuilder parentConfigurationParameters(ConfigurationParameters configurationParameters)
Set the parent configuration parameters to use for the request.Any explicit configuration parameters configured via
configurationParameter(String, String)
orconfigurationParameters(Map)
takes precedence over the supplied configuration parameters.- Parameters:
configurationParameters
- the parent instance to be used for looking up configuration parameters that have not been explicitly configured; nevernull
- Since:
- 1.8
- See Also:
configurationParameter(String, String)
,configurationParameters(Map)
-
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
- theLauncherDiscoveryListeners
to add; nevernull
- Returns:
- this builder for method chaining
- Since:
- 1.6
- 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.properties
classpath resource. Passingfalse
to this method, disables the latter two sources so that only explicit configuration parameters are taken into account.- Since:
- 1.7
- See Also:
configurationParameter(String, String)
,configurationParameters(Map)
-
storeFilter
private void storeFilter(Filter<?> filter)
-
build
public LauncherDiscoveryRequest build()
Build theLauncherDiscoveryRequest
that has been configured via this builder.
-
buildLauncherConfigurationParameters
private LauncherConfigurationParameters buildLauncherConfigurationParameters()
-
getLauncherDiscoveryListener
private LauncherDiscoveryListener getLauncherDiscoveryListener(ConfigurationParameters configurationParameters)
-
getDefaultLauncherDiscoveryListener
private LauncherDiscoveryListener getDefaultLauncherDiscoveryListener(ConfigurationParameters configurationParameters)
-
-