org.junit.platform.launcher.TestExecutionListener源码实例Demo

类org.junit.platform.launcher.TestExecutionListener源码实例Demo

下面列出了org.junit.platform.launcher.TestExecutionListener 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 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);
}
 
@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);
}
 
源代码3 项目: tutorials   文件: TestLauncher.java
public static void main(String[] args) {

        //@formatter:off
        LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
                .selectors(selectClass("com.baeldung.EmployeesUnitTest"))
                .configurationParameter("junit.conditions.deactivate", "com.baeldung.extensions.*")
                .configurationParameter("junit.jupiter.extensions.autodetection.enabled", "true")
                .build();
        
        //@formatter:on

        TestPlan plan = LauncherFactory.create()
            .discover(request);
        Launcher launcher = LauncherFactory.create();
        SummaryGeneratingListener summaryGeneratingListener = new SummaryGeneratingListener();
        launcher.execute(request, new TestExecutionListener[] { summaryGeneratingListener });
        launcher.execute(request);

        summaryGeneratingListener.getSummary()
            .printTo(new PrintWriter(System.out));

    }
 
源代码4 项目: sbt-jupiter-interface   文件: JupiterRunner.java
Task[] execute() {

            String testSuiteName = taskDef.fullyQualifiedName();

            Configuration configuration = new Configuration(testSuiteName, loggers, options);
            Dispatcher dispatcher = new Dispatcher(configuration, eventHandler);

            SummaryPrintingTestListener summaryListener = new SummaryPrintingTestListener(configuration);
            TestExecutionListener outputCapturingListener = new OutputCapturingTestListener(
                    configuration, systemStreamPair);

            JupiterTestListener testListener = configuration.getTestListener();

            try
            {
                LauncherDiscoveryRequestBuilder builder = LauncherDiscoveryRequestBuilder.request();
                builder.selectors(testSelector(testSuiteName));
                builder.filters(testFilters(dispatcher));

                Launcher launcher = LauncherFactory.create();

                launcher.registerTestExecutionListeners(dispatcher);
                launcher.registerTestExecutionListeners(outputCapturingListener);
                launcher.registerTestExecutionListeners(summaryListener);
                launcher.registerTestExecutionListeners(testListener);

                configuration.createRunListener(testClassLoader)
                        .ifPresent(launcher::registerTestExecutionListeners);

                launcher.execute(builder.build(), new TestExecutionListener[0]);

                return new Task[0];
            }
            catch (Throwable t) {
                dispatcher.executionFailed(testSuiteName, t);
                t.printStackTrace();
                return new Task[0];
            }
        }
 
源代码5 项目: sbt-jupiter-interface   文件: Configuration.java
/**
 * Creates instances of test listeners using the specified {@code classLoader}.
 *
 * @param classLoader The class loader which should be used to load test listeners.
 * @return The list of test listener instances supplied via the command line.
 */
public Optional<TestExecutionListener> createRunListener(ClassLoader classLoader) {

    return options.getRunListener().map(className -> {

        try {
            final Object listener = classLoader.loadClass(className).newInstance();
            return (TestExecutionListener)listener;
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
}
 
源代码6 项目: jeka   文件: ProgressListeners.java
static TestExecutionListener get(JkTestProcessor.JkProgressOutputStyle progressDisplayer) {
    if (progressDisplayer == null) {
        return null;
    }
    switch (progressDisplayer) {
        case TREE: return new ProgressListeners.TreeProgressExecutionListener();
        case FULL: return new ProgressListeners.ConsoleProgressExecutionListener();
        case ONE_LINE: return new ProgressListeners.OneLineProgressExecutionListener();
        case SILENT: return new SilentProgressExecutionListener();
        default: return null;
    }
}
 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法