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 ConfigurationParameters getConfigurationParameters() { return new NoConfigurationParameters(); }
@Override protected Object getEngine(ConfigurationParameters config) { return SimpleClojure.invoke("org.ajoberstar.jovial.engine.clojure-test", "engine", config); }
/** * Extract amount of scoops to generate. */ int getScoops(EngineDiscoveryRequest discoveryRequest, int defaultScoops) { ConfigurationParameters parameters = discoveryRequest.getConfigurationParameters(); String scoops = parameters.get("scoops").orElse(Integer.toString(defaultScoops)); return Integer.valueOf(scoops); }
protected abstract Object getEngine(ConfigurationParameters config);