Class SuiteLauncherDiscoveryRequestBuilder
SuiteLauncherDiscoveryRequestBuilder provides a light-weight DSL
for generating a LauncherDiscoveryRequest specifically tailored for
suite execution.
Example
SuiteLauncherDiscoveryRequestBuilder.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(Paths.get("/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("key", "value")
.enableImplicitConfigurationParameters(true)
.applyConfigurationParametersFromSuite(MySuite.class)
.applySelectorsAndFiltersFromSuite(MySuite.class)
.build();
- Since:
- 1.8
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionapplyConfigurationParametersFromSuite(Class<?> suiteClass) Apply a suite's annotation-based configuration to this builder.applySelectorsAndFiltersFromSuite(Class<?> suiteClass) Apply a suite's annotation-based discovery selectors and filters to this builder.build()Build theLauncherDiscoveryRequestthat has been configured via this builder.configurationParameter(String key, String value) Add the supplied configuration parameter to the request.configurationParameters(Map<String, String> configurationParameters) Add all supplied configuration parameters to the request.configurationParametersResource(String resourceFile) enableImplicitConfigurationParameters(boolean enabled) Configure whether implicit configuration parameters should be considered.Add all suppliedfiltersto the request.filterStandardClassNamePatterns(boolean filterStandardClassNamePatterns) Specify whether to filter standard class name patterns.outputDirectoryProvider(OutputDirectoryProvider outputDirectoryProvider) parentConfigurationParameters(ConfigurationParameters parentConfigurationParameters) Set the parent configuration parameters to use for the request.request()Create a newSuiteLauncherDiscoveryRequestBuilder.selectors(List<? extends DiscoverySelector> selectors) Add all suppliedselectorsto the request.selectors(DiscoverySelector... selectors) Add all suppliedselectorsto the request.Deprecated.
-
Method Details
-
request
Create a newSuiteLauncherDiscoveryRequestBuilder.- Returns:
- a new builder
-
selectors
Add all suppliedselectorsto the request.- Parameters:
selectors- theDiscoverySelectorsto add; nevernull- Returns:
- this builder for method chaining
-
selectors
Add all suppliedselectorsto the request.- Parameters:
selectors- theDiscoverySelectorsto add; nevernull- Returns:
- this builder for method chaining
-
filters
Add all 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
-
filterStandardClassNamePatterns
public SuiteLauncherDiscoveryRequestBuilder filterStandardClassNamePatterns(boolean filterStandardClassNamePatterns) Specify whether to filter standard class name patterns.If set to
true, standard class name patterns are filtered.- Parameters:
filterStandardClassNamePatterns-trueto filter standard class name patterns,falseotherwise- Returns:
- this builder for method chaining
-
configurationParameter
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 SuiteLauncherDiscoveryRequestBuilder configurationParameters(Map<String, String> configurationParameters) Add all supplied configuration parameters to the request.- Parameters:
configurationParameters- the map of configuration parameters to add; nevernull- Returns:
- this builder for method chaining
- See Also:
-
configurationParametersResource
-
parentConfigurationParameters
public SuiteLauncherDiscoveryRequestBuilder parentConfigurationParameters(ConfigurationParameters parentConfigurationParameters) 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:
parentConfigurationParameters- the parent instance to use for looking up configuration parameters that have not been explicitly configured; nevernull- Returns:
- this builder for method chaining
- See Also:
-
enableImplicitConfigurationParameters
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.- Parameters:
enabled-trueif implicit configuration parameters should be considered- Returns:
- this builder for method chaining
- See Also:
-
outputDirectoryProvider
public SuiteLauncherDiscoveryRequestBuilder outputDirectoryProvider(OutputDirectoryProvider outputDirectoryProvider) -
suite
Deprecated.as of JUnit Platform 1.11 in favor ofapplyConfigurationParametersFromSuite(java.lang.Class<?>)andapplySelectorsAndFiltersFromSuite(java.lang.Class<?>)Apply a suite's annotation-based configuration, selectors, and filters to this builder.- Parameters:
suiteClass- the class to apply the annotations from; nevernull- Returns:
- this builder for method chaining
- See Also:
-
applyConfigurationParametersFromSuite
public SuiteLauncherDiscoveryRequestBuilder applyConfigurationParametersFromSuite(Class<?> suiteClass) Apply a suite's annotation-based configuration to this builder.This will apply the configuration from the following annotations.
- Parameters:
suiteClass- the class to apply the configuration annotations from; nevernull- Returns:
- this builder for method chaining
- Since:
- 1.11
- See Also:
-
applySelectorsAndFiltersFromSuite
Apply a suite's annotation-based discovery selectors and filters to this builder.This will apply the configuration from the following annotations.
- Parameters:
suiteClass- the class to apply the discovery selectors and filter annotations from; nevernull- Returns:
- this builder for method chaining
- Since:
- 1.11
- See Also:
-
build
Build theLauncherDiscoveryRequestthat has been configured via this builder.
-
applyConfigurationParametersFromSuite(java.lang.Class<?>)andapplySelectorsAndFiltersFromSuite(java.lang.Class<?>)