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();
public Builder withArg(final String arg) { this.runtimeOptions = new RuntimeOptions(arg); return this; }
/** * 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); }
RuntimeOptions runtimeOptions = runtimeOptionsFactory.create(); reporter = runtimeOptions.reporter(classLoader); formatter = runtimeOptions.formatter(classLoader); isStrict = runtimeOptions.isStrict(); List<Object> filters = runtimeOptions.getFilters(); String classPackagePath = clazz.getName(); classPackagePath = classPackagePath.substring(0, Math.max(0, classPackagePath.lastIndexOf("."))).replace('.', for (String format : reportformatList) { Object formatObj = pluginFactory.create(format); runtimeOptions.addPlugin(formatObj); runtimeOptions.getGlue().clear(); //fix the duplicate step definition exception runtimeOptions.getGlue().addAll(stepdefinitionList); cucumberFeatures = CucumberFeature.load(resourceLoader, featurePaths, filters);
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(); } }
Assertions.assertNoCucumberAnnotatedMethods(clazz); RuntimeOptions runtimeOptions = new RuntimeOptions(cucumberOptions); ResourceLoader resourceLoader = new MultiLoader(classLoader); FeatureLoader featureLoader = new FeatureLoader(resourceLoader); 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();
public void performInternalCucumberOperations(final Object testInstance, final TEST_NOTIFIER runNotifier) throws Exception { final Class<?> javaTestClass = getTestedClass(); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); final InputStream configurationInputStream = classLoader.getResourceAsStream(ClientServerFiles.CONFIG); final Properties cukespaceConfigurationProperties = loadCucumberConfigurationProperties(configurationInputStream); final RuntimeOptions runtimeOptions = loadRuntimeOptions(javaTestClass, cukespaceConfigurationProperties); final boolean reported = Boolean.parseBoolean(cukespaceConfigurationProperties.getProperty(CucumberConfiguration.REPORTABLE, "false")); final StringBuilder reportBuilder = new StringBuilder(); if (reported) { runtimeOptions.addPlugin(new JSONFormatter(reportBuilder)); } final InputStream gluesInputStream = classLoader.getResourceAsStream(ClientServerFiles.GLUES_LIST); final Collection<Class<?>> glues = loadGlues(gluesInputStream, classLoader, javaTestClass); final ArquillianBackend arquillianBackend = new ArquillianBackend( glues, javaTestClass, testInstance, cukespaceConfigurationProperties.getProperty(CucumberConfiguration.OBJECT_FACTORY)); final CucumberRuntime cucumberRuntime = new CucumberRuntime(null, classLoader, singletonList(arquillianBackend), runtimeOptions); final Map<String, Collection<URL>> featuresMap = Features.createFeatureMap(CucumberConfiguration.instance().getTempDir(), cukespaceConfigurationProperties.getProperty(CucumberConfiguration.FEATURE_HOME), javaTestClass, classLoader); final List<CucumberFeature> cucumberFeatures = getCucumberFeatures(runtimeOptions.getFilters(), testInstance, classLoader, featuresMap); final Formatter formatter = runtimeOptions.formatter(classLoader); final Reporter reporter = runtimeOptions.reporter(classLoader); final StepDefinitionReporter stepDefinitionReporter = runtimeOptions.stepDefinitionReporter(classLoader); cucumberRuntime.getGlue().reportStepDefinitions(stepDefinitionReporter); runFeatures(cucumberFeatures, cucumberRuntime, getReporter(reporter, formatter, runtimeOptions), runNotifier); if (reported) { final String path = cukespaceConfigurationProperties.getProperty(CucumberConfiguration.REPORTABLE_PATH); addReportTestIntoFile(path, javaTestClass, reportBuilder); } handleCucumberTestErrors(cucumberRuntime.getErrors(), cucumberRuntime); }
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; }
/** * 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()); }
/** * {@inheritDoc} */ @Override public void addPlugin(Object plugin) { this.ros.addPlugin(plugin); }
runtimeOptions = new RuntimeOptions(cucumberOptions); ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader); runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions); testSelectedFeatures.addAll(runtimeOptions.cucumberFeatures(resourceLoader));
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"); } }
/** * Initialization of JavaBackend with {@link FluentObjectFactory} for FluentCucumber tests. * * @return backend with {@link FluentObjectFactory} */ private JavaBackend getBackend(ClassFinder classFinder, RuntimeOptions runtimeOptions, FluentObjectFactory objectFactory) { Reflections reflections = new Reflections(classFinder); TypeRegistryConfigurer typeRegistryConfigurer = reflections.instantiateExactlyOneSubclass(TypeRegistryConfigurer.class, MultiLoader.packageName(runtimeOptions.getGlue()), new Class[0], new Object[0], new DefaultTypeRegistryConfiguration()); return new JavaBackend(objectFactory, classFinder, new TypeRegistry(typeRegistryConfigurer.locale())); }
EnvironmentVariables environmentVariables = Injectors.getInjector().getInstance(EnvironmentVariables.class); RuntimeOptions runtimeOptions = currentRuntimeOptions(); List<String> tagFilters = runtimeOptions.getTagFilters(); List<String> featurePaths = runtimeOptions.getFeaturePaths(); int batchNumber = environmentVariables.getPropertyAsInteger(SERENITY_BATCH_NUMBER, 1); int batchCount = environmentVariables.getPropertyAsInteger(SERENITY_BATCH_COUNT, 1);
/** * {@inheritDoc} */ @Override public List<String> getFeaturePaths() { return this.ros.getFeaturePaths(); }
/** * {@inheritDoc} */ @Override public List<CucumberFeature> cucumberFeatures(ResourceLoader resourceLoader) { return this.ros.cucumberFeatures(resourceLoader); }
public ExtendedRuntime(ResourceLoader resourceLoaderValue, ClassLoader classLoaderValue, Collection<? extends Backend> backendsValue, RuntimeOptions runtimeOptionsValue, StopWatch stopWatchValue, RuntimeGlue optionalGlueValue) { super(resourceLoaderValue, classLoaderValue, backendsValue, runtimeOptionsValue, stopWatchValue, optionalGlueValue); if (backendsValue.isEmpty()) { throw new CucumberException( "No backends were found. Please make sure you have a backend module on your CLASSPATH."); } //this.resourceLoader = resourceLoaderValue; this.classLoader = classLoaderValue; this.backends = backendsValue; this.runtimeOptions = runtimeOptionsValue; this.stopWatch = stopWatchValue; if (optionalGlueValue != null) { this.glue = optionalGlueValue; } else { this.glue = new RuntimeGlue( undefinedStepsTracker, new LocalizedXStreams(classLoaderValue)); } this.stats = new Stats(runtimeOptionsValue.isMonochrome()); for (Backend backend : backends) { backend.loadGlue(glue, runtimeOptions.getGlue()); backend.setUnreportedStepExecutor(this); } }
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,