io.cucumber.core.options.CommandlineOptionsParser Java Examples

The following examples show how to use io.cucumber.core.options.CommandlineOptionsParser. 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: AllureCucumber5JvmTest.java    From allure-java with Apache License 2.0 7 votes vote down vote up
private byte runFeature(final AllureResultsWriterStub writer,
                        final String featureResource,
                        final String... moreOptions) {

    final AllureLifecycle lifecycle = new AllureLifecycle(writer);
    final AllureCucumber5Jvm cucumber5Jvm = new AllureCucumber5Jvm(lifecycle);
    Supplier<ClassLoader> classLoader = ClassLoaders::getDefaultClassLoader;
    final List<String> opts = new ArrayList<>(Arrays.asList(
            "--glue", "io.qameta.allure.cucumber5jvm.samples",
            "--plugin", "null_summary"
    ));
    opts.addAll(Arrays.asList(moreOptions));
    FeatureWithLines featureWithLines = FeatureWithLines.parse("src/test/resources/"+featureResource);
    final RuntimeOptions options = new CommandlineOptionsParser().parse(opts).addFeature(featureWithLines).build();
    boolean mt = options.isMultiThreaded();

    EventBus bus = new TimeServiceEventBus(Clock.systemUTC(), UUID::randomUUID);
    FeatureParser parser = new FeatureParser(bus::generateId);
    FeaturePathFeatureSupplier supplier = new FeaturePathFeatureSupplier(classLoader, options, parser);

    final Runtime runtime = Runtime.builder()
            .withClassLoader(classLoader)
            .withRuntimeOptions(options)
            .withAdditionalPlugins(cucumber5Jvm)
            .withFeatureSupplier(supplier)
            .build();

    runtime.run();
    return runtime.exitStatus();
}
 
Example #2
Source File: FeatureBuilder.java    From cucumber-performance with MIT License 6 votes vote down vote up
public static RuntimeOptions createRuntimeOptions(List<String> args) {
	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 CommandlineOptionsParser().parse(args).build(envOptions);
	return runtimeOptions;
}
 
Example #3
Source File: AllureCucumber4JvmTest.java    From allure-java with Apache License 2.0 6 votes vote down vote up
private byte runFeature(final AllureResultsWriterStub writer,
                        final String featureResource,
                        final String... moreOptions) {

    final AllureLifecycle lifecycle = new AllureLifecycle(writer);
    final AllureCucumber4Jvm cucumber4Jvm = new AllureCucumber4Jvm(lifecycle);
    final ClassLoader classLoader = currentThread().getContextClassLoader();
    final ResourceLoader resourceLoader = new MultiLoader(classLoader);
    final ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
    final List<String> opts = new ArrayList<>(Arrays.asList(
            "--glue", "io.qameta.allure.cucumber4jvm.samples",
            "--plugin", "null_summary"
    ));
    opts.addAll(Arrays.asList(moreOptions));
    final RuntimeOptions options = new CommandlineOptionsParser().parse(opts).build();
    boolean mt = options.isMultiThreaded();

    FeatureSupplier featureSupplier = () -> {
        try {
            final String gherkin = readResource(featureResource);
            Parser<GherkinDocument> parser = new Parser<>(new AstBuilder());
            TokenMatcher matcher = new TokenMatcher();
            GherkinDocument gherkinDocument = parser.parse(gherkin, matcher);
            List<PickleEvent> pickleEvents = compilePickles(gherkinDocument, featureResource);
            CucumberFeature feature = new CucumberFeature(gherkinDocument, URI.create(featureResource), gherkin, pickleEvents);

            return Collections.singletonList(feature);
        } catch (IOException e) {
            return Collections.EMPTY_LIST;
        }
    };
    final Runtime runtime = Runtime.builder()
            .withResourceLoader(resourceLoader)
            .withClassFinder(classFinder)
            .withClassLoader(classLoader)
            .withRuntimeOptions(options)
            .withAdditionalPlugins(cucumber4Jvm)
            .withFeatureSupplier(featureSupplier)
            .build();

    runtime.run();
    return runtime.exitStatus();
}
 
Example #4
Source File: CourgetteRuntimeOptions.java    From courgette-jvm with MIT License 6 votes vote down vote up
public RuntimeOptions getRuntimeOptions() {
    return new CommandlineOptionsParser().parse(runtimeOptions).build();
}