Class LauncherDiscoveryRequestBuilder

java.lang.Object
org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder

@API(status=STABLE, since="1.0") public final class LauncherDiscoveryRequestBuilder extends Object
The LauncherDiscoveryRequestBuilder provides a light-weight DSL for generating a LauncherDiscoveryRequest.

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(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("key1", "value1")
     .configurationParameters(configParameterMap)
     .build();
 
Since:
1.0
See Also:
  • Field Details

    • DEFAULT_DISCOVERY_LISTENER_CONFIGURATION_PROPERTY_NAME

      public static final 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:
  • Constructor Details

  • Method Details