public Runtime build() { final ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader : new MultiLoader(this.classLoader); final ClassFinder classFinder = this.classFinder != null ? this.classFinder : new ResourceLoaderClassFinder(resourceLoader, this.classLoader); final BackendSupplier backendSupplier = this.backendSupplier != null ? this.backendSupplier : new BackendModuleBackendSupplier(resourceLoader, classFinder, this.runtimeOptions); final Plugins plugins = new Plugins(this.classLoader, new PluginFactory(), this.eventBus, this.runtimeOptions); for (final Plugin plugin : additionalPlugins) { plugins.addPlugin(plugin); } final RunnerSupplier runnerSupplier = runtimeOptions.isMultiThreaded() ? new ThreadLocalRunnerSupplier(this.runtimeOptions, eventBus, backendSupplier) : new SingletonRunnerSupplier(this.runtimeOptions, eventBus, backendSupplier); final ExecutorService executor = runtimeOptions.isMultiThreaded() ? Executors.newFixedThreadPool(runtimeOptions.getThreads()) : new SameThreadExecutorService(); final FeatureLoader featureLoader = new FeatureLoader(resourceLoader); final FeatureSupplier featureSupplier = this.featureSupplier != null ? this.featureSupplier : new FeaturePathFeatureSupplier(featureLoader, this.runtimeOptions); final Filters filters = new Filters(this.runtimeOptions); return new Runtime(plugins, this.runtimeOptions, eventBus, filters, runnerSupplier, featureSupplier, executor); } }
/** * 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(); } }
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(); } }
@Override public void run(RunNotifier notifier) { super.run(notifier); jUnitReporter.done(); jUnitReporter.close(); runtime.printSummary(); }
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(); } } }
/** * Constructor for FluentCucumber. * * @param clazz runner class * @throws InitializationError problem with initialization * @throws IOException problem with reading feature files */ public FluentCucumber(Class clazz) throws InitializationError, IOException { super(clazz); ClassLoader classLoader = clazz.getClassLoader(); Assertions.assertNoCucumberAnnotatedMethods(clazz); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); ResourceLoader resourceLoader = new MultiLoader(classLoader); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); FluentObjectFactory objectFactory = getFluentObjectFactory(clazz); this.runtime = new Runtime(resourceLoader, classLoader, singletonList(getBackend(classFinder, runtimeOptions, objectFactory)), runtimeOptions); Formatter formatter = runtimeOptions.formatter(classLoader); JUnitOptions junitOptions = new JUnitOptions(runtimeOptions.getJunitOptions()); List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader, this.runtime.getEventBus()); this.jUnitReporter = new JUnitReporter(this.runtime.getEventBus(), runtimeOptions.isStrict(), junitOptions); this.addChildren(cucumberFeatures); }
/** * 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 finish() { Formatter formatter = runtimeOptions.formatter(classLoader); formatter.done(); formatter.close(); runtime.printSummary(); if (!runtime.getSnippets().isEmpty()) { throw new CucumberException("Some steps could not be found"); } }
private boolean isPendingOrUndefined(Result result) { Throwable error = result.getError(); return Result.UNDEFINED == result || isPending(error); }
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(); } }
@Override public void run(RunNotifier notifier) { super.run(notifier); jUnitReporter.done(); jUnitReporter.close(); runtime.printSummary(); }
@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); }
/** * Constructor for FluentCucumber. * * @param clazz runner class * @throws InitializationError problem with initialization * @throws IOException problem with reading feature files */ public FluentCucumber(Class clazz) throws InitializationError, IOException { super(clazz); ClassLoader classLoader = clazz.getClassLoader(); Assertions.assertNoCucumberAnnotatedMethods(clazz); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); ResourceLoader resourceLoader = new MultiLoader(classLoader); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); FluentObjectFactory objectFactory = getFluentObjectFactory(clazz); this.runtime = new Runtime(resourceLoader, classLoader, singletonList(getBackend(classFinder, runtimeOptions, objectFactory)), runtimeOptions); Formatter formatter = runtimeOptions.formatter(classLoader); JUnitOptions junitOptions = new JUnitOptions(runtimeOptions.getJunitOptions()); List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader, this.runtime.getEventBus()); this.jUnitReporter = new JUnitReporter(this.runtime.getEventBus(), runtimeOptions.isStrict(), junitOptions); this.addChildren(cucumberFeatures); }
private boolean isPendingOrUndefined(Result result) { Throwable error = result.getError(); return Result.UNDEFINED == result || isPending(error); }
/** * Create the Runtime. Can be overridden to customize the runtime or backend. * * @param resourceLoader used to load resources * @param classLoader used to load classes * @param runtimeOptions configuration * @return a new runtime */ protected Runtime createRuntime(ResourceLoader resourceLoader, ClassLoader classLoader, RuntimeOptions runtimeOptions) { ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); return new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); }
/** * 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(); } }
@Override public void run(RunNotifier notifier) { // notifier.addListener(new SanityChecker()); super.run(notifier); becauseCucumberReporter.done(); becauseCucumberReporter.close(); runtime.printSummary(); // after the execution if (reportInstance != null) { RefelectionUtils.getMethod(reportInstance, METHOD_AFTERRUN, new Object[] {}); } }
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(); } } }
private boolean isPendingOrUndefined(Result result) { Throwable error = result.getError(); return Result.UNDEFINED == result || isPending(error); }
/** * Create the Runtime. Can be overridden to customize the runtime or backend. * * @param resourceLoader used to load resources * @param classLoader used to load classes * @param runtimeOptions configuration * @return a new runtime */ protected Runtime createRuntime(ResourceLoader resourceLoader, ClassLoader classLoader, RuntimeOptions runtimeOptions) { ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); return new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); }