/** * 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; }
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; } } }
public JupiterTestEngineForTests(Containers containers, JupiterExecutionListener eventRecorder) { this.containers = containers; this.eventRecorder = eventRecorder; this.engine = new JupiterTestEngine(); }