cucumber.api.cli.Main Maven / Gradle / Ivy
package cucumber.api.cli;
import cucumber.runtime.ClassFinder;
import cucumber.runtime.Runtime;
import cucumber.runtime.RuntimeOptions;
import cucumber.runtime.io.MultiLoader;
import cucumber.runtime.io.ResourceLoader;
import cucumber.runtime.io.ResourceLoaderClassFinder;
import java.io.IOException;
import java.util.ArrayList;
import static java.util.Arrays.asList;
public class Main {
public static void main(String[] argv) {
byte exitstatus = run(argv, Thread.currentThread().getContextClassLoader());
System.exit(exitstatus);
}
/**
* 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 runtimeOptions = new RuntimeOptions(new ArrayList(asList(argv)));
ResourceLoader resourceLoader = new MultiLoader(classLoader);
ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
runtime.run();
return runtime.exitStatus();
}
}