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; } } }
@Override public void execute(ExecutionRequest request) { TestDescriptor engine = request.getRootTestDescriptor(); EngineExecutionListener listener = request.getEngineExecutionListener(); listener.executionStarted(engine); for (TestDescriptor child : engine.getChildren()) { listener.executionStarted(child); listener.executionFinished(child, TestExecutionResult.successful()); } listener.executionFinished(engine, TestExecutionResult.successful()); }