public byte exitStatus() { if (results.isEmpty()) { return DEFAULT; } if (runtimeOptions.isWip()) { return min(results, SEVERITY).is(Result.Type.PASSED) ? ERRORS : DEFAULT; } return max(results, SEVERITY).isOk(runtimeOptions.isStrict()) ? DEFAULT : ERRORS; } }
public void runScenario(PickleEvent pickle) throws Throwable { //Possibly invoked in a multi-threaded context Runner runner = runnerSupplier.get(); TestCaseResultListener testCaseResultListener = new TestCaseResultListener(runner.getBus(), runtimeOptions.isStrict()); runner.runPickle(pickle); testCaseResultListener.finishExecutionUnit(); if (!testCaseResultListener.isPassed()) { throw testCaseResultListener.getError(); } }
this.runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier); this.filters = new Filters(runtimeOptions); this.junitOptions = new JUnitOptions(runtimeOptions.isStrict(), runtimeOptions.getJunitOptions()); final StepDefinitionReporter stepDefinitionReporter = plugins.stepDefinitionReporter();
/** * {@inheritDoc} */ @Override public boolean isStrict() { return this.ros.isStrict(); }
/** * 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); }
void printStats(PrintStream out) { stats.printStats(out, runtimeOptions.isStrict()); }
private boolean hasUndefinedOrPendingStepsAndIsStrict() { return runtimeOptions.isStrict() && hasUndefinedOrPendingSteps(); }
/** * Bootstrap the cucumber runtime * * @param clazz Which has the cucumber.api.CucumberOptions and org.testng.annotations.Test annotations */ public CustomTestNGCucumberRunner(Class<?> clazz) { classLoader = clazz.getClassLoader(); resourceLoader = new MultiLoader(classLoader); cucumberFeatures = initCucumberOptions(clazz); resultListener = new FeatureResultListener(runtimeOptions.reporter(classLoader), runtimeOptions.isStrict()); }
@Override protected FormaterReporterFacade getReporter(final Reporter delegate, final Formatter formatter, final RuntimeOptions runtimeOptions) { return new FormaterReporterFacade(new FeatureResultListener(delegate, runtimeOptions.isStrict()), formatter); } }
@Override protected JUnitReporter getReporter(final Reporter delegate, final Formatter formatter, final RuntimeOptions runtimeOptions) { return new JUnitReporter( delegate, formatter, runtimeOptions.isStrict(), new JUnitOptions(runtimeOptions.getJunitOptions())); } };
/** * Constructor called by JUnit. * * @param clazz the class with the @RunWith annotation. * @throws java.io.IOException if there is a problem * @throws org.junit.runners.model.InitializationError if there is another problem */ public CucumberLoadRunner(Class clazz) throws InitializationError, IOException { super(clazz); System.setProperty(cukesProperty(CONTEXT_INFLATING_ENABLED), "false"); System.setProperty(cukesProperty(ASSERTIONS_DISABLED), "true"); System.setProperty(cukesProperty(LOADRUNNER_FILTER_BLOCKS_REQUESTS), "true"); System.setProperty(AssertionFacade.ASSERTION_FACADE, AssertionFacadeLoadRunnerImpl.class.getCanonicalName()); System.setProperty(VariableFacade.VARIABLE_FACADE, VariableFacadeLoadRunnerImpl.class.getCanonicalName()); filter = SingletonObjectFactory.instance().getInstance(LoadRunnerFilter.class); ClassLoader classLoader = clazz.getClassLoader(); Assertions.assertNoCucumberAnnotatedMethods(clazz); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); ResourceLoader resourceLoader = new MultiLoader(classLoader); runtime = createRuntime(resourceLoader, classLoader, runtimeOptions); final List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader); jUnitReporter = new JUnitReporter(runtimeOptions.reporter(classLoader), runtimeOptions.formatter(classLoader), runtimeOptions.isStrict(), new JUnitOptions(runtimeOptions.getJunitOptions())); addChildren(cucumberFeatures); }
isStrict = runtimeOptions.isStrict();
private void init(RuntimeOptions runtimeOptions, ClassLoader classLoader, ResourceLoader resourceLoader) throws Exception { for (ExtendedRuntimeOptions option : extendedOptions) { retryCount = Math.max(retryCount, option.getRetryCount()); threadsCount = Math.max(threadsCount, option.getThreadsCount()); } final JUnitOptions junitOptions = new JUnitOptions(runtimeOptions.getJunitOptions()); final List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader); jUnitReporter = new JUnitReporter( runtimeOptions.reporter(classLoader), runtimeOptions.formatter(classLoader), runtimeOptions.isStrict(), junitOptions); Method[] retryMethods = this.getPredefinedMethods(RetryAcceptance.class); addChildren(cucumberFeatures, retryMethods); } protected Runtime createRuntime(ResourceLoader resourceLoader, ClassLoader classLoader,
isStrict = runtimeOptions.isStrict();
public void runScenario(PickleEvent pickle) throws Throwable { //Possibly invoked in a multi-threaded context Runner runner = runnerSupplier.get(); TestCaseResultListener testCaseResultListener = new TestCaseResultListener(runner.getBus(), runtimeOptions.isStrict()); runner.runPickle(pickle); testCaseResultListener.finishExecutionUnit(); if (!testCaseResultListener.isPassed()) { throw testCaseResultListener.getError(); } }
@Override public List<FeatureRunner> getChildren() { final RuntimeOptions runtimeOptions = courgetteLoader.getRuntimeOptions(); final EventBus eventBus = courgetteLoader.getEventBus(); final ResourceLoader resourceLoader = courgetteLoader.getResourceLoader(); final ClassFinder classFinder = courgetteLoader.getClassFinder(); final Filters filters = courgetteLoader.getFilters(); final JUnitOptions jUnitOptions = new JUnitOptions(runtimeOptions.isStrict(), runtimeOptions.getJunitOptions()); final BackendSupplier backendSupplier = new BackendModuleBackendSupplier(resourceLoader, classFinder, runtimeOptions); final ThreadLocalRunnerSupplier runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, eventBus, backendSupplier); final List<FeatureRunner> children = new ArrayList<>(); this.cucumberFeatures.forEach(cucumberFeature -> { try { FeatureRunner runner = new FeatureRunner(cucumberFeature, filters, runnerSupplier, jUnitOptions); runner.getDescription(); children.add(runner); } catch (InitializationError error) { error.printStackTrace(); } }); return children; }
/** * Constructor called by JUnit. * * @param clazz the class with the @RunWith annotation. * @throws java.io.IOException if there is a problem * @throws org.junit.runners.model.InitializationError if there is another problem */ public CucumberLoadRunner(Class clazz) throws InitializationError, IOException { super(clazz); System.setProperty(cukesProperty(CONTEXT_INFLATING_ENABLED), "false"); System.setProperty(cukesProperty(ASSERTIONS_DISABLED), "true"); System.setProperty(cukesProperty(LOADRUNNER_FILTER_BLOCKS_REQUESTS), "true"); filter = SingletonObjectFactory.instance().getInstance(LoadRunnerFilter.class); ClassLoader classLoader = clazz.getClassLoader(); Assertions.assertNoCucumberAnnotatedMethods(clazz); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); ResourceLoader resourceLoader = new MultiLoader(classLoader); runtime = createRuntime(resourceLoader, classLoader, runtimeOptions); final List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader); jUnitReporter = new JUnitReporter(runtimeOptions.reporter(classLoader), runtimeOptions.formatter(classLoader), runtimeOptions.isStrict(), new JUnitOptions(runtimeOptions.getJunitOptions())); addChildren(cucumberFeatures); }
/** * 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); }
this.filters = new Filters(runtimeOptions, rerunFilters); this.junitOptions = new JUnitOptions(runtimeOptions.isStrict(), runtimeOptions.getJunitOptions()); Plugins plugins = new Plugins(classLoader, new PluginFactory(), bus, runtimeOptions); final StepDefinitionReporter stepDefinitionReporter = plugins.stepDefinitionReporter();