Search in sources :

Example 1 with CommandlineOptionsParser

use of io.cucumber.core.options.CommandlineOptionsParser in project cucumber-jvm by cucumber.

the class Main method run.

/**
 * Launches the Cucumber-JVM command line.
 *
 * @param  argv        runtime options. See details in the
 *                     {@code cucumber.api.cli.Usage.txt} resource.
 * @param  classLoader classloader used to load the runtime
 * @return             0 if execution was successful, 1 if it was not (test
 *                     failures)
 */
public static byte run(String[] argv, ClassLoader classLoader) {
    RuntimeOptions propertiesFileOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromPropertiesFile()).build();
    RuntimeOptions environmentOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromEnvironment()).build(propertiesFileOptions);
    RuntimeOptions systemOptions = new CucumberPropertiesParser().parse(CucumberProperties.fromSystemProperties()).build(environmentOptions);
    CommandlineOptionsParser commandlineOptionsParser = new CommandlineOptionsParser(System.out);
    RuntimeOptions runtimeOptions = commandlineOptionsParser.parse(argv).addDefaultGlueIfAbsent().addDefaultFeaturePathIfAbsent().addDefaultSummaryPrinterIfNotDisabled().enablePublishPlugin().build(systemOptions);
    Optional<Byte> exitStatus = commandlineOptionsParser.exitStatus();
    if (exitStatus.isPresent()) {
        return exitStatus.get();
    }
    final Runtime runtime = Runtime.builder().withRuntimeOptions(runtimeOptions).withClassLoader(() -> classLoader).build();
    runtime.run();
    return runtime.exitStatus();
}
Also used : CucumberPropertiesParser(io.cucumber.core.options.CucumberPropertiesParser) Runtime(io.cucumber.core.runtime.Runtime) CommandlineOptionsParser(io.cucumber.core.options.CommandlineOptionsParser) RuntimeOptions(io.cucumber.core.options.RuntimeOptions)

Aggregations

CommandlineOptionsParser (io.cucumber.core.options.CommandlineOptionsParser)1 CucumberPropertiesParser (io.cucumber.core.options.CucumberPropertiesParser)1 RuntimeOptions (io.cucumber.core.options.RuntimeOptions)1 Runtime (io.cucumber.core.runtime.Runtime)1