org.junit.jupiter.engine.JupiterTestEngine Java Examples
The following examples show how to use
org.junit.jupiter.engine.JupiterTestEngine.
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: TestClassExecutor.java From webtester2-core with Apache License 2.0 | 6 votes |
public static void execute(Class<?> testClass) throws Exception { try { JupiterTestEngine engine = new JupiterTestEngine(); TestClassEngineDiscoveryRequest discoveryRequest = new TestClassEngineDiscoveryRequest(testClass); TestDescriptor testDescriptor = engine.discover(discoveryRequest, UniqueId.forEngine("foo-bar")); EngineExecutionListener listener = new NoOpEngineExecutionListener(); ConfigurationParameters parameters = new NoConfigurationParameters(); engine.execute(new ExecutionRequest(testDescriptor, listener, parameters)); } catch (UndeclaredThrowableException e) { Throwable cause = getFirstNonUndeclaredThrowableCause(e); if (cause instanceof Error) { throw ( Error ) cause; } else if (cause instanceof RuntimeException) { throw ( RuntimeException ) cause; } else if (cause instanceof Exception) { throw ( Exception ) cause; } else { throw e; } } }
Example #2
Source File: JunitRunner.java From vespa with Apache License 2.0 | 5 votes |
public String executeTests(List<Class<?>> testClasses) { LauncherDiscoveryRequest discoveryRequest = LauncherDiscoveryRequestBuilder.request() .selectors( testClasses.stream().map(DiscoverySelectors::selectClass).collect(Collectors.toList()) ) .build(); var launcherConfig = LauncherConfig.builder() .addTestEngines(new JupiterTestEngine()) .build(); Launcher launcher = LauncherFactory.create(launcherConfig); // Create log listener: var logLines = new ArrayList<String>(); var logListener = LoggingListener.forBiConsumer((t, m) -> log(logLines, m.get(), t)); // Create a summary listener: var summaryListener = new SummaryGeneratingListener(); launcher.registerTestExecutionListeners(logListener, summaryListener); // Execute request launcher.execute(discoveryRequest); var report = summaryListener.getSummary(); return createJsonTestReport(report, logLines); }
Example #3
Source File: JupiterTestEngineForTests.java From junit5-docker with Apache License 2.0 | 4 votes |
public JupiterTestEngineForTests(Containers containers, JupiterExecutionListener eventRecorder) { this.containers = containers; this.eventRecorder = eventRecorder; this.engine = new JupiterTestEngine(); }