/** * Launches the Cucumber-JVM command line. * * @param argv runtime options. See details in the {@code cucumber.api.cli.Usage.txt} resource. * @param classLoader classloader used to load the runtime * @return 0 if execution was successful, 1 if it was not (test failures) */ public static byte run(String[] argv, ClassLoader classLoader) { final Runtime runtime = Runtime.builder() .withArgs(argv) .withClassLoader(classLoader) .build(); runtime.run(); return runtime.exitStatus(); } }
/** * Run the Cucumber features */ public void runCukes() { try { LOGGER.trace("Running cucumber tests on [{}]", TestContext.getCurrent()); runtime.run(); } catch (IOException ex) { throw new RuntimeException(ex); } if (!runtime.getErrors().isEmpty()) { throw new CucumberException(runtime.getErrors().get(0)); } else if (runtime.exitStatus() != 0x00) { throw new CucumberException("There are pending or undefined steps."); } }
@Override protected void runChild(ParentRunner child, RunNotifier notifier) { System.out.println("Running Feature child (scenario)..."); try { System.out.println("Begin scenario run..."); child.run(notifier); Assert.assertEquals(0, this.getRuntime().exitStatus()); } catch (AssumptionViolatedException e) { System.out.println("Scenario AssumptionViolatedException..."); } catch (Throwable e) { List<Throwable> errors = this.getRuntime().getErrors(); Throwable error = errors.get(errors.size() - 1); if (ExtendedCucumber.isRetryApplicable(error, this.retryMethods)) { System.out.println("Initiating retry..."); retry(notifier, child, error); } } finally { System.out.println("Scenario completed..." + this.getRuntime().exitStatus()); } this.setScenarioCount(this.getScenarioCount() + 1); this.setFailedAttempts(0); }
/** * Launches the Cucumber-JVM command line * @param argv runtime options. See details in the {@code cucumber.api.cli.Usage.txt} resource * @param classLoader classloader used to load the runtime * @return 0 if execution was successful, 1 if not (there were test failures) * @throws IOException if resources couldn't be loaded during execution */ public static byte run(String[] argv, ClassLoader classLoader) throws IOException { RuntimeOptions runtimeOptions = new RuntimeOptions(asList(argv)); ResourceLoader resourceLoader = new MultiLoader(classLoader); Configuration systemConfiguration = Injectors.getInjector().getInstance(Configuration.class); Runtime seleniumRuntime = CucumberWithSerenity.createSerenityEnabledRuntime(resourceLoader, classLoader, runtimeOptions, systemConfiguration); seleniumRuntime.run(); return seleniumRuntime.exitStatus(); } }
/** * Launches the Cucumber-JVM command line * @param argv runtime options. See details in the {@code cucumber.api.cli.Usage.txt} resource * @param classLoader classloader used to load the runtime * @return 0 if execution was successful, 1 if not (there were test failures) * @throws IOException if resources couldn't be loaded during execution */ public static byte run(String[] argv, ClassLoader classLoader) throws IOException { RuntimeOptions runtimeOptions = new RuntimeOptions(asList(argv)); ResourceLoader resourceLoader = new MultiLoader(classLoader); Configuration systemConfiguration = Injectors.getInjector().getInstance(Configuration.class); Runtime seleniumRuntime = CucumberWithSerenity.createSerenityEnabledRuntime(resourceLoader, classLoader, runtimeOptions, systemConfiguration); seleniumRuntime.run(); return seleniumRuntime.exitStatus(); } }
/** * Launches the Cucumber-JVM command line. * * @param argv runtime options. See details in the {@code cucumber.api.cli.Usage.txt} resource. * @param classLoader classloader used to load the runtime * @return 0 if execution was successful, 1 if it was not (test failures) * @throws IOException if resources couldn't be loaded during the run. */ public static byte run(String[] argv, ClassLoader classLoader) throws IOException { byte exitstatus = 0; for (Object[] parameters : Configuration.current().createWrappersParameters()) { if (exitstatus != 0) { break; } RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<>(asList(argv))); ResourceLoader resourceLoader = new MultiLoader(classLoader); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); Runtime runtime = new ParameterizableRuntime(resourceLoader, classFinder, classLoader, runtimeOptions, parameters[0].toString(), parameters); runtime.run(); exitstatus = runtime.exitStatus(); } return exitstatus; } }
public static byte run(String[] argv, ClassLoader classLoader) throws IOException { RuntimeOptions runtimeOptions = new RuntimeOptions(Arrays.asList(argv)); ResourceLoader resourceLoader = new MultiLoader(classLoader); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); CucumberWithSerenity.setRuntimeOptions(runtimeOptions); Runtime runtime = CucumberWithSerenityRuntime.using(resourceLoader, classLoader, classFinder, runtimeOptions); runtime.run(); return runtime.exitStatus(); } }
public static byte run(String[] argv, ClassLoader classLoader) throws IOException { RuntimeOptions runtimeOptions = new RuntimeOptions(Arrays.asList(argv)); ResourceLoader resourceLoader = new MultiLoader(classLoader); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); CucumberWithSerenity.setRuntimeOptions(runtimeOptions); Runtime runtime = CucumberWithSerenityRuntime.using(resourceLoader, classLoader, classFinder, runtimeOptions); runtime.run(); return runtime.exitStatus(); } }
public void retry(RunNotifier notifier, ParentRunner child, Throwable currentThrowable) { ParentRunner featureElementRunner = null; Class<? extends ParentRunner> clazz = child.getClass(); System.out.println("Current class is: " + clazz.getCanonicalName()); CucumberScenario scenario = getCurrentScenario(child); if (scenario == null) { return; } runtime.getErrors().clear(); while (this.getRetryCount() > this.getFailedAttempts()) { try { featureElementRunner = new ExtendedExecutionUnitRunner( runtime, scenario, jUnitReporter); featureElementRunner.run(notifier); Assert.assertEquals(0, runtime.exitStatus()); runtime.getErrors().clear(); return; } catch (Throwable t) { this.setFailedAttempts(this.getFailedAttempts() + 1); runtime.getErrors().clear(); } } }
@Override protected void runChild(Runner runner, RunNotifier notifier) { ExtendedExecutionUnitRunner featureElementRunner = (ExtendedExecutionUnitRunner) runner; try { featureElementRunner = new ExtendedExecutionUnitRunner( runtime, ((ExtendedExecutionUnitRunner) runner).getCucumberScenario(), jUnitReporter); featureElementRunner.run(notifier); Assert.assertEquals(0, this.getRuntime().exitStatus()); } catch (AssumptionViolatedException e) { System.out.println("Scenario AssumptionViolatedException..."); } catch (Throwable e) { System.out.println( ((ExtendedExecutionUnitRunner) runner).getCucumberScenario().getGherkinModel().getId()); System.out.println(e.getClass().getCanonicalName() + ":" + e.getMessage()); List<Throwable> errors = this.getRuntime().getErrors(); Throwable error = errors.get(errors.size() - 1); if (ExtendedCucumber.isRetryApplicable(error, this.retryMethods)) { System.out.println("===Initiating retry..."); retry(notifier, featureElementRunner, e); } } finally { System.out.println(((ExtendedExecutionUnitRunner) runner).getCucumberScenario().getGherkinModel().getId() + "Scenario completed..." + this.getRuntime().exitStatus()); } this.setScenarioCount(this.getScenarioCount() + 1); this.setFailedAttempts(0); }
public void retry(RunNotifier notifier, ParentRunner child, Throwable currentThrowable) { ParentRunner featureElementRunner = null; Class<? extends ParentRunner> clazz = child.getClass(); System.out.println("Current class is: " + clazz.getCanonicalName()); CucumberScenario scenario = getCurrentScenario(); if (scenario == null) { return; } this.getRuntime().getErrors().clear(); while (this.getRetryCount() > this.getFailedAttempts()) { try { featureElementRunner = new ExtendedExecutionUnitRunner( runtime, scenario, jUnitReporter); featureElementRunner.run(notifier); Assert.assertEquals(0, this.getRuntime().exitStatus()); this.getRuntime().getErrors().clear(); return; } catch (Throwable t) { this.setFailedAttempts(this.getFailedAttempts() + 1); this.getRuntime().getErrors().clear(); } } }