Java 类org.junit.platform.launcher.listeners.SummaryGeneratingListener 实例源码

项目:mastering-junit5    文件:LauncherApiExample.java   
@SuppressWarnings("unused")
public static void main(String[] args) {
    // Discover and filter tests
    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder
            .request()
            .selectors(selectPackage("io.github.bonigarcia"),
                    selectClass(DummyTest.class))
            .filters(includeClassNamePatterns(".*Test")).build();

    Launcher launcher = LauncherFactory.create();
    TestPlan plan = launcher.discover(request);

    // Executing tests
    TestExecutionListener listener = new SummaryGeneratingListener();
    launcher.registerTestExecutionListeners(listener);

    launcher.execute(request, listener);
}
项目:Mastering-Software-Testing-with-JUnit-5    文件:LauncherApiExample.java   
@SuppressWarnings("unused")
public static void main(String[] args) {
    // Discover and filter tests
    LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder
            .request()
            .selectors(selectPackage("io.github.bonigarcia"),
                    selectClass(DummyTest.class))
            .filters(includeClassNamePatterns(".*Test")).build();

    Launcher launcher = LauncherFactory.create();
    TestPlan plan = launcher.discover(request);

    // Executing tests
    TestExecutionListener listener = new SummaryGeneratingListener();
    launcher.registerTestExecutionListeners(listener);

    launcher.execute(request, listener);
}
项目:pro    文件:TesterRunner.java   
private static int launch(ModuleReference moduleReference, Launcher launcher) {
  LauncherDiscoveryRequestBuilder builder = LauncherDiscoveryRequestBuilder.request();
  builder.selectors(selectModule(moduleReference.descriptor().name()));

  long startTimeMillis = System.currentTimeMillis();
  LauncherDiscoveryRequest launcherDiscoveryRequest = builder.build();
  SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();
  launcher.execute(launcherDiscoveryRequest, summaryGeneratingListener);
  long duration = System.currentTimeMillis() - startTimeMillis;

  TestExecutionSummary summary = summaryGeneratingListener.getSummary();
  int failures = (int) summary.getTestsFailedCount();
  if (failures == 0) {
    long succeeded = summary.getTestsSucceededCount();
    String moduleName = moduleReference.descriptor().toNameAndVersion();
    System.out.printf("[tester] Successfully tested %s: %d tests in %d ms%n", moduleName, succeeded, duration);
  } else {
    StringWriter stringWriter = new StringWriter();
    summary.printTo(new PrintWriter(stringWriter));
    summary.printFailuresTo(new PrintWriter(stringWriter));
    System.out.println(stringWriter);
  }
  return failures;
}
项目: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;
}