io.cucumber.core.options.CucumberOptionsAnnotationParser Java Examples
The following examples show how to use
io.cucumber.core.options.CucumberOptionsAnnotationParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CucumberOptionsProvider.java From cucumber-performance with MIT License | 5 votes |
@Override public CucumberOptionsAnnotationParser.CucumberOptions getOptions(Class<?> clazz) { CucumberOptions annotation = clazz.getAnnotation(CucumberOptions.class); if (annotation == null) { return null; } return new GenericCucumberOptions(annotation); }
Example #2
Source File: FeatureBuilder.java From cucumber-performance with MIT License | 5 votes |
public static RuntimeOptions createRuntimeOptions(Class<?> clazz) { RuntimeOptions propertiesFileOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromPropertiesFile()).build(); RuntimeOptions systemOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromSystemProperties()) .build(propertiesFileOptions); RuntimeOptions envOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromEnvironment()).build(systemOptions); RuntimeOptions runtimeOptions = new CucumberOptionsAnnotationParser().withOptionsProvider(new CucumberOptionsProvider()).parse(clazz).build(envOptions); return runtimeOptions; }
Example #3
Source File: CucumberTestUnitFinder.java From pitest-cucumber-plugin with Apache License 2.0 | 5 votes |
@Override public CucumberOptionsAnnotationParser.CucumberOptions getOptions(Class<?> clazz) { // this is ok since up to Cucumber 4.7.1, il will fallback on cucumber.api.CucumberOptions // @see io.cucumber.core.options.CucumberOptionsAnnotationParser (l.41) final io.cucumber.junit.CucumberOptions annotation = clazz.getAnnotation(io.cucumber.junit.CucumberOptions.class); if (annotation == null) { return null; } return new CustomCucumberOptions(annotation); }
Example #4
Source File: JustTestLahRunner.java From justtestlah with Apache License 2.0 | 4 votes |
/** * This is the code taken from {@link io.cucumber.junit.Cucumber} * * @param clazz {@link Class} * @throws InitializationError {@link InitializationError} */ private void initCucumber(Class<?> clazz) throws InitializationError { Assertions.assertNoCucumberAnnotatedMethods(clazz); // Parse the options early to provide fast feedback about invalid options RuntimeOptions propertiesFileOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromPropertiesFile()).build(); RuntimeOptions annotationOptions = new CucumberOptionsAnnotationParser() .withOptionsProvider(new JUnitCucumberOptionsProvider()) .parse(clazz) .build(propertiesFileOptions); RuntimeOptions environmentOptions = new CucumberPropertiesParser() .parse(CucumberProperties.fromEnvironment()) .build(annotationOptions); RuntimeOptions runtimeOptions = new CucumberPropertiesParser() .parse(CucumberProperties.fromSystemProperties()) .addDefaultSummaryPrinterIfAbsent() .build(environmentOptions); if (!runtimeOptions.isStrict()) { LOG.warn( "By default Cucumber is running in --non-strict mode.\n" + "This default will change to --strict and --non-strict will be removed.\n" + "You can use --strict or @CucumberOptions(strict = true) to suppress this warning"); } // Next parse the junit options JUnitOptions junitPropertiesFileOptions = new JUnitOptionsParser().parse(CucumberProperties.fromPropertiesFile()).build(); JUnitOptions junitAnnotationOptions = new JUnitOptionsParser().parse(clazz).build(junitPropertiesFileOptions); JUnitOptions junitEnvironmentOptions = new JUnitOptionsParser() .parse(CucumberProperties.fromEnvironment()) .build(junitAnnotationOptions); JUnitOptions junitOptions = new JUnitOptionsParser() .parse(CucumberProperties.fromSystemProperties()) .setStrict(runtimeOptions.isStrict()) .build(junitEnvironmentOptions); this.bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID); // Parse the features early. Don't proceed when there are lexer errors FeatureParser parser = new FeatureParser(bus::generateId); Supplier<ClassLoader> classLoader = ClassLoaders::getDefaultClassLoader; FeaturePathFeatureSupplier featureSupplier = new FeaturePathFeatureSupplier(classLoader, runtimeOptions, parser); this.features = featureSupplier.get(); // Create plugins after feature parsing to avoid the creation of empty files on // lexer errors. this.plugins = new Plugins(new PluginFactory(), runtimeOptions); ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(runtimeOptions); ObjectFactorySupplier objectFactorySupplier = new ThreadLocalObjectFactorySupplier(objectFactoryServiceLoader); BackendSupplier backendSupplier = new BackendServiceLoader(clazz::getClassLoader, objectFactorySupplier); TypeRegistryConfigurerSupplier typeRegistryConfigurerSupplier = new ScanningTypeRegistryConfigurerSupplier(classLoader, runtimeOptions); ThreadLocalRunnerSupplier runnerSupplier = new ThreadLocalRunnerSupplier( runtimeOptions, bus, backendSupplier, objectFactorySupplier, typeRegistryConfigurerSupplier); Predicate<Pickle> filters = new Filters(runtimeOptions); this.children = features.stream() .map(feature -> FeatureRunner.create(feature, filters, runnerSupplier, junitOptions)) .filter(runner -> !runner.isEmpty()) .collect(toList()); LOG.info( "Found {} feature(s) in {}: {}", features.size(), System.getProperty("cucumber.features"), features); }
Example #5
Source File: CucumberTestUnitFinder.java From pitest-cucumber-plugin with Apache License 2.0 | 4 votes |
public List<TestUnit> findTestUnits(Class<?> junitTestClass) { if (hasACucumberAnnotation(junitTestClass)) { List<TestUnit> result = new ArrayList<>(); RuntimeOptions runtimeOptions = new CucumberOptionsAnnotationParser() .withOptionsProvider(new CustomProvider()) .parse(junitTestClass) .build(); TimeServiceEventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID); FeatureParser parser = new FeatureParser(bus::generateId); FeatureSupplier featureSupplier = new FeaturePathFeatureSupplier(junitTestClass::getClassLoader, runtimeOptions, parser); final List<Feature> cucumberFeatures = featureSupplier.get(); final Filters filters = new Filters(runtimeOptions); EventBus eventBus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID); ObjectFactoryServiceLoader objectFactoryServiceLoader = new ObjectFactoryServiceLoader(runtimeOptions); ObjectFactorySupplier objectFactorySupplier = new ThreadLocalObjectFactorySupplier(objectFactoryServiceLoader); BackendSupplier backendSupplier = new BackendServiceLoader(junitTestClass::getClassLoader, objectFactorySupplier); TypeRegistryConfigurerSupplier typeRegistryConfigurerSupplier = new ScanningTypeRegistryConfigurerSupplier(junitTestClass::getClassLoader, runtimeOptions); RunnerSupplier runnerSupplier = new SingletonRunnerSupplier(runtimeOptions, eventBus, backendSupplier, objectFactorySupplier, typeRegistryConfigurerSupplier); for (Feature feature : cucumberFeatures) { Log.getLogger().fine("Found feature \"" + feature.getName() + "\""); List<Pickle> pickles = feature.getPickles(); for (Pickle pickle : pickles) { if (!filters.test(pickle)) continue; Description description = new Description( feature.getName() + " : " + pickle.getName(), junitTestClass); Log.getLogger().fine("Found \"" + description.getName() + "\""); result.add(new ScenarioTestUnit(description, pickle, runnerSupplier, eventBus)); } } return result; } return Collections.emptyList(); }