/** * 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."); } }
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(); } } }
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(); } } }
@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); }
@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); }