/** * Bootstrap the cucumber runtime * * @param clazz Which has the cucumber.api.CucumberOptions and org.testng.annotations.Test annotations */ public TestNGCucumberRunner(Class clazz) { ClassLoader classLoader = clazz.getClassLoader(); ResourceLoader resourceLoader = new MultiLoader(classLoader); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); runtimeOptions = runtimeOptionsFactory.create(); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); BackendModuleBackendSupplier backendSupplier = new BackendModuleBackendSupplier(resourceLoader, classFinder, runtimeOptions); bus = new TimeServiceEventBus(TimeService.SYSTEM); new Plugins(classLoader, new PluginFactory(), bus, runtimeOptions); FeatureLoader featureLoader = new FeatureLoader(resourceLoader); filters = new Filters(runtimeOptions); this.runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier); featureSupplier = new FeaturePathFeatureSupplier(featureLoader, runtimeOptions); }
private List<String> buildArgsFromOptions() { List<String> args = new ArrayList<String>(); for (Class classWithOptions = clazz; hasSuperClass(classWithOptions); classWithOptions = classWithOptions.getSuperclass()) { CucumberOptions options = getOptions(classWithOptions); if (options != null) { addDryRun(options, args); addMonochrome(options, args); addTags(options, args); addPlugins(options, args); addStrict(options, args); addName(options, args); addSnippets(options, args); addGlue(options, args); addFeatures(options, args); addJunitOptions(options, args); } } addDefaultFeaturePathIfNoFeaturePathIsSpecified(args, clazz); addDefaultGlueIfNoOverridingGlueIsSpecified(args, clazz); return args; }
Assertions.assertNoCucumberAnnotatedMethods(clazz); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
/** * 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); }
ClassLoader classLoader=getClass().getClassLoader(); ResourceLoader resourceLoader=new MultiLoader(classLoader); RuntimeOptionsFactory roFactory=new RuntimeOptionsFactory(getClass()); RuntimeOptions ro=roFactory.create(); ro.getGlue().clear(); ro.getGlue().add("applications.StepDefinitions"); ro.getFeaturePaths().clear(); String feature = "src/applications/Features"; ro.getFeaturePaths().add(feature); ro.getFilters().add("@Scenario1"); ClassFinder classFinder=new ResourceLoaderClassFinder(resourceLoader,classLoader); cucumber.runtime.Runtime runtime=new cucumber.runtime.Runtime(resourceLoader,classFinder,classLoader,ro); try { runtime.run(); } catch (RuntimeException ex) { throw new RuntimeException(ex); } and also updated the gherkin jar to 2.12.2 and this worked fine
public ExtendedCucumber(Class clazz) throws Exception { super(clazz); this.clazzValue = clazz; 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); extendedOptions = ExtendedRuntimeOptions.init(clazz); init(runtimeOptions, classLoader, resourceLoader); } public ExtendedCucumber(
public Runtime build() { if (classLoader == null) classLoader = testClass == null ? Thread.currentThread().getContextClassLoader() : testClass.getClassLoader(); if (resourceLoader == null) resourceLoader = new MultiLoader(classLoader); if (pluginFactory == null) pluginFactory = new PluginFactory(); if (runtimeOptions == null) { Preconditions.checkArgument(!args.isEmpty() || testClass != null, "RuntimeOptions not provided, need args or testClass"); runtimeOptions = args.isEmpty() ? new RuntimeOptionsFactory(testClass).create() : new RuntimeOptions(pluginFactory, args); } runtimeOptions.getFeaturePaths().addAll(featurePaths); for (Object plugin : plugins) { runtimeOptions.addPlugin(plugin); } String progressOutputFilePath = System.getProperty("minium.cucumber.progressOutputFile", null); if (progressOutputFilePath != null) { File progressOutputFile = new File(progressOutputFilePath); runtimeOptions.addPlugin(new ProgressFormatter(progressOutputFile)); } runtime = new Runtime(resourceLoader, classLoader, backends, runtimeOptions); return runtime; }
private static RuntimeOptions loadRuntimeOptions(final Class<?> javaTestClass, final Properties cukespaceConfigurationProperties) { final RuntimeOptions runtimeOptions; if (javaTestClass.getAnnotation(CucumberOptions.class) != null) { // by class setting final RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(javaTestClass); runtimeOptions = runtimeOptionsFactory.create(); cleanClasspathList(runtimeOptions.getGlue()); cleanClasspathList(runtimeOptions.getFeaturePaths()); } else if (cukespaceConfigurationProperties.containsKey(CucumberConfiguration.OPTIONS)) { // arquillian setting runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm"), asList((cukespaceConfigurationProperties.getProperty(CucumberConfiguration.OPTIONS, "--strict") + " --strict").split(" "))); } else { // default runtimeOptions = new RuntimeOptions(new Env("cucumber-jvm"), asList("--strict", "--plugin", "pretty", areColorsNotAvailable(cukespaceConfigurationProperties))); } return runtimeOptions; }
public static cucumber.runtime.Runtime serenityRunnerForCucumberTestRunner(Class testClass, Configuration systemConfiguration) { ClassLoader classLoader = testClass.getClassLoader(); ResourceLoader resourceLoader = new MultiLoader(classLoader); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(testClass); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); return CucumberWithSerenity.createSerenityEnabledRuntime(resourceLoader, classLoader, runtimeOptions, systemConfiguration); }
/** * Bootstrap the cucumber runtime * * @param clazz Which has the cucumber.api.CucumberOptions and org.testng.annotations.Test annotations */ public TestNGZucchiniRunner(Class<?> clazz) { ClassLoader classLoader = clazz.getClassLoader(); ResourceLoader resourceLoader = new MultiLoader(classLoader); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); /* Add the custom Zucchini Formatter */ CucumberJSONFormatter formatter = new CucumberJSONFormatter(output); runtimeOptions.addPlugin(formatter); this.formatters = getAllPlugins(runtimeOptions); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); runtime = new ZucchiniRuntime(resourceLoader, classFinder, classLoader, runtimeOptions); }
RuntimeOptions runtimeOptionsB = new RuntimeOptionsFactory(clazz).create();
public static cucumber.runtime.Runtime serenityRunnerForCucumberTestRunner(Class testClass, File outputDirectory, EnvironmentVariables environmentVariables) { ClassLoader classLoader = testClass.getClassLoader(); ResourceLoader resourceLoader = new MultiLoader(classLoader); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(testClass); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); Configuration systemConfiguration = new SystemPropertiesConfiguration(environmentVariables); systemConfiguration.setOutputDirectory(outputDirectory); return CucumberWithSerenity.createSerenityEnabledRuntime(resourceLoader, classLoader, runtimeOptions, systemConfiguration); }
/** * 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); }
/** * Bootstrap the cucumber runtime * * @param clazz Which has the cucumber.api.CucumberOptions and org.testng.annotations.Test annotations */ public TestNGCucumberRunner(Class clazz) { ClassLoader classLoader = clazz.getClassLoader(); ResourceLoader resourceLoader = new MultiLoader(classLoader); RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); runtimeOptions = runtimeOptionsFactory.create(); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); BackendModuleBackendSupplier backendSupplier = new BackendModuleBackendSupplier(resourceLoader, classFinder, runtimeOptions); bus = new TimeServiceEventBus(TimeService.SYSTEM); new Plugins(classLoader, new PluginFactory(), bus, runtimeOptions); FeatureLoader featureLoader = new FeatureLoader(resourceLoader); filters = new Filters(runtimeOptions); this.runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier); featureSupplier = new FeaturePathFeatureSupplier(featureLoader, runtimeOptions); }
RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(clazz); RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
/** * 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); }