Java 类org.junit.platform.engine.DiscoverySelector 实例源码

项目:junit-extensions    文件:ExtensionTester.java   
/**
 * Instance an engine and execute the test resources identified by the given {@code selectors} and
 * wrap the response in a listener so that we can make sense of what happened. The listener
 * exposes information about the test execution flow which the extension tests can assert against.
 *
 * @param selectors {@link DiscoverySelector} instances which will isolate test class or test
 *     methods
 * @return a {@link RecordingExecutionListener} which encapsulates what the engine did
 */
public static RecordingExecutionListener execute(DiscoverySelector... selectors) {
  // instance an engine
  JupiterTestEngine testEngine = new JupiterTestEngine();

  // discover the requested test resources
  LauncherDiscoveryRequest discoveryRequest = request().selectors(selectors).build();

  RecordingExecutionListener listener = new RecordingExecutionListener();

  // execute the discovered test resources
  TestDescriptor testDescriptor =
      testEngine.discover(discoveryRequest, UniqueId.forEngine(testEngine.getId()));
  testEngine.execute(
      new ExecutionRequest(
          testDescriptor, listener, discoveryRequest.getConfigurationParameters()));

  return listener;
}
项目:verify-matching-service-adapter    文件:Application.java   
public ExitStatus execute(SummaryGeneratingListener listener,
                          DiscoverySelector selector,
                          ApplicationConfiguration applicationConfiguration,
                          FilesLocator filesLocator) {
    ApplicationConfigurationResolver.setConfiguration(applicationConfiguration);
    FilesLocatorResolver.setFilesLocator(filesLocator);

    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
        .selectors(selector)
        .build();

    Launcher launcher = LauncherFactory.create();
    launcher.registerTestExecutionListeners(listener);
    launcher.execute(request);

    return listener.getSummary().getFailures().isEmpty() ? ExitStatus.SUCCESS : ExitStatus.FAILURE;
}
项目:webtester2-core    文件:TestClassExecutor.java   
@Override
@SuppressWarnings("unchecked")
public <T extends DiscoverySelector> List<T> getSelectorsByType(Class<T> selectorType) {
    if (ClassSelector.class.equals(selectorType)) {
        List<T> list = new ArrayList<>();
        list.add(( T ) DiscoverySelectors.selectClass(testClass));
        return list;
    }
    return Collections.emptyList();
}
项目:junit-pioneer    文件:AbstractPioneerTestEngineTests.java   
private ExecutionEventRecorder executeTestMethods(Class<?> type, String[] methodNames) {
    //@formatter:off
    DiscoverySelector[] selectors = stream(methodNames)
            .map(methodName -> selectMethod(type, methodName))
            .toArray(DiscoverySelector[]::new);
    //@formatter:on
    LauncherDiscoveryRequest request = request().selectors(selectors).build();
    return executeTests(request);
}