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.*;
import static org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder.discoveryRequest;
// ...
LauncherDiscoveryRequest discoveryRequest = discoveryRequest()
.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),
selectUniqueId("unique-id-1"),
selectUniqueId("unique-id-2")
)
.selectors(
selectClasspathRoots(Set.of(Paths.get("/my/local/path1")))
)
.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();
org.junit.platform.engine.discovery.DiscoverySelectors , org.junit.platform.engine.discovery.ClassNameFilter , org.junit.platform.launcher.EngineFilter , org.junit.platform.launcher.TagFilter , LauncherExecutionRequestBuilder
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final List | |
| public static final String | DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAME
Property name used to set the default discovery listener that is added to all : Supported Values Supported values are |
| private static final String | |
| private final List | |
| private final List | |
| private final List | |
| private boolean | |
| private @Nullable OutputDirectoryCreator | |
| private @Nullable ConfigurationParameters | |
| private final List | |
| private final List |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public LauncherDiscoveryRequest | |
| private LauncherConfigurationParameters | |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe configuration parameter key under which to store the
value; never key, String null or blankthe value to store value)Add the supplied configuration parameter to the request. |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe map of configuration parameters to add;
never configurationParameters)nullAdd all supplied configuration parameters to the request. |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe classpath locations of the properties files
never paths)nullAdd all of the supplied configuration parameters resource files to the request. |
| public static LauncherDiscoveryRequestBuilder | |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingtrue if implicit configuration parameters should be
consideredConfigure whether implicit configuration parameters should be considered. |
| public LauncherDiscoveryRequestBuilder | |
| public LauncherExecutionRequestBuilder | Returns: a newLauncherExecutionRequestBuilderBuilds this discovery request and returns a new builder for creating a
|
| private LauncherDiscoveryListener | |
| private LauncherDiscoveryListener | |
| private OutputDirectoryCreator | |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe listeners)LauncherDiscoveryListeners to add; never
nullAdd all supplied discovery listeners to the request. |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe output directory creator to use;
never outputDirectoryCreator)nullSet the |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe output directory provider to use;
never outputDirectoryProvider)null
Deprecated
for removal since 1.14. Please use
outputDirectoryCreator(OutputDirectoryCreator) instead
Set the
|
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe parent instance to use for looking
up configuration parameters that have not been explicitly configured;
never parentConfigurationParameters)nullSet the parent configuration parameters to use for the request. |
| public static LauncherDiscoveryRequestBuilder | |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe selectors)DiscoverySelectors to add; never nullAdd all supplied |
| public LauncherDiscoveryRequestBuilder | Returns: this builder for method chainingthe selectors)DiscoverySelectors to add; never nullAdd all supplied |
| private void |
| configurationParameters | back to summary |
|---|---|
| private final Map<String, String> configurationParameters | |
| configurationParametersResources | back to summary |
|---|---|
| private final List<String> configurationParametersResources | |
| DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAME | back to summary |
|---|---|
| public static final String DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAME Property name used to set the default discovery listener that is added to all : Supported ValuesSupported values are If not specified, the default is abortOnFailure. | |
| DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_VALUE | back to summary |
|---|---|
| private static final String DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_VALUE | |
| discoveryFilters | back to summary |
|---|---|
| private final List<DiscoveryFilter<?>> discoveryFilters | |
| discoveryListeners | back to summary |
|---|---|
| private final List<LauncherDiscoveryListener> discoveryListeners | |
| engineFilters | back to summary |
|---|---|
| private final List<EngineFilter> engineFilters | |
| implicitConfigurationParametersEnabled | back to summary |
|---|---|
| private boolean implicitConfigurationParametersEnabled | |
| outputDirectoryCreator | back to summary |
|---|---|
| private @Nullable OutputDirectoryCreator outputDirectoryCreator | |
| parentConfigurationParameters | back to summary |
|---|---|
| private @Nullable ConfigurationParameters parentConfigurationParameters | |
| postDiscoveryFilters | back to summary |
|---|---|
| private final List<PostDiscoveryFilter> postDiscoveryFilters | |
| selectors | back to summary |
|---|---|
| private final List<DiscoverySelector> selectors | |
| LauncherDiscoveryRequestBuilder | back to summary |
|---|---|
| private LauncherDiscoveryRequestBuilder() | |
| build | back to summary |
|---|---|
| public LauncherDiscoveryRequest build() Build the | |
| buildLauncherConfigurationParameters | back to summary |
|---|---|
| private LauncherConfigurationParameters buildLauncherConfigurationParameters() | |
| configurationParameter | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder configurationParameter(String key, String value) Add the supplied configuration parameter to the request.
| |
| configurationParameters | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder configurationParameters(Map<String, String> configurationParameters) Add all supplied configuration parameters to the request.
| |
| configurationParametersResources | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder configurationParametersResources(String... paths) Add all of the supplied configuration parameters resource files to the request.
| |
| discoveryRequest | back to summary |
|---|---|
| public static LauncherDiscoveryRequestBuilder discoveryRequest() Create a new This method is an alias for
| |
| enableImplicitConfigurationParameters | back to summary |
|---|---|
| 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
| |
| filters | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder filters(Filter<?>... filters) Add all supplied The Warning be cautious when registering multiple competing
| |
| forExecution | back to summary |
|---|---|
| public LauncherExecutionRequestBuilder forExecution() Builds this discovery request and returns a new builder for creating a
| |
| getDefaultLauncherDiscoveryListener | back to summary |
|---|---|
| private LauncherDiscoveryListener getDefaultLauncherDiscoveryListener(ConfigurationParameters configurationParameters) | |
| getLauncherDiscoveryListener | back to summary |
|---|---|
| private LauncherDiscoveryListener getLauncherDiscoveryListener(ConfigurationParameters configurationParameters) | |
| getOutputDirectoryCreator | back to summary |
|---|---|
| private OutputDirectoryCreator getOutputDirectoryCreator(LauncherConfigurationParameters configurationParameters) | |
| listeners | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder listeners(LauncherDiscoveryListener... listeners) Add all 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.
| |
| outputDirectoryCreator | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder outputDirectoryCreator(OutputDirectoryCreator outputDirectoryCreator) Set the If not specified, a default implementation will be used that can be configured via the junit.platform.reporting.output.dir configuration parameter.
| |
| outputDirectoryProvider | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder outputDirectoryProvider(OutputDirectoryProvider outputDirectoryProvider)
Set the
If not specified, a default provider will be used that can be configured via the junit.platform.reporting.output.dir configuration parameter.
| |
| parentConfigurationParameters | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder parentConfigurationParameters(ConfigurationParameters parentConfigurationParameters) Set the parent configuration parameters to use for the request. Any explicit configuration parameters configured via
| |
| request | back to summary |
|---|---|
| public static LauncherDiscoveryRequestBuilder request() Create a new
| |
| selectors | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder selectors(DiscoverySelector... selectors) Add all supplied
| |
| selectors | back to summary |
|---|---|
| public LauncherDiscoveryRequestBuilder selectors(List<? extends DiscoverySelector> selectors) Add all supplied
| |
| storeFilter | back to summary |
|---|---|
| private void storeFilter(Filter<?> filter) | |