org.junit.platform.launcher.TestExecutionListener Java Examples
The following examples show how to use
org.junit.platform.launcher.TestExecutionListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LauncherApiExample.java From Mastering-Software-Testing-with-JUnit-5 with MIT License | 5 votes |
@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); }
Example #2
Source File: Configuration.java From sbt-jupiter-interface with Apache License 2.0 | 5 votes |
/** * 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); } }); }
Example #3
Source File: ProgressListeners.java From jeka with Apache License 2.0 | 5 votes |
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; } }
Example #4
Source File: TestLauncher.java From tutorials with MIT License | 5 votes |
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)); }
Example #5
Source File: LauncherApiExample.java From mastering-junit5 with Apache License 2.0 | 4 votes |
@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); }
Example #6
Source File: JupiterRunner.java From sbt-jupiter-interface with Apache License 2.0 | 4 votes |
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]; } }