use of cucumber.runtime.io.ResourceLoader 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)
* @throws IOException if resources couldn't be loaded during the run.
*/
public static byte run(String[] argv, ClassLoader classLoader) throws IOException {
RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList<String>(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();
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class RuntimeTest method createRuntime.
private Runtime createRuntime(String... runtimeArgs) {
ResourceLoader resourceLoader = mock(ResourceLoader.class);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return createRuntime(resourceLoader, classLoader, runtimeArgs);
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class RuntimeTest method createRuntimeWithMockedGlue.
private Runtime createRuntimeWithMockedGlue(StepDefinitionMatch match, boolean isAmbiguous, HookDefinition hook, boolean isBefore, String... runtimeArgs) {
ResourceLoader resourceLoader = mock(ResourceLoader.class);
ClassLoader classLoader = mock(ClassLoader.class);
RuntimeOptions runtimeOptions = new RuntimeOptions(asList(runtimeArgs));
Backend backend = mock(Backend.class);
RuntimeGlue glue = mock(RuntimeGlue.class);
mockMatch(glue, match, isAmbiguous);
mockHook(glue, hook, isBefore);
Collection<Backend> backends = Arrays.asList(backend);
return new Runtime(resourceLoader, classLoader, backends, runtimeOptions, glue);
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class MethodScannerTest method loadGlue_registers_the_methods_declaring_class_in_the_object_factory.
@Test
public void loadGlue_registers_the_methods_declaring_class_in_the_object_factory() throws NoSuchMethodException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ResourceLoader resourceLoader = new MultiLoader(classLoader);
MethodScanner methodScanner = new MethodScanner(new ResourceLoaderClassFinder(resourceLoader, classLoader));
ObjectFactory factory = Mockito.mock(ObjectFactory.class);
Glue world = Mockito.mock(Glue.class);
JavaBackend backend = new JavaBackend(factory);
Whitebox.setInternalState(backend, "glue", world);
// this delegates to methodScanner.scan which we test
methodScanner.scan(backend, BaseStepDefs.class.getMethod("m"), BaseStepDefs.class);
verify(factory, times(1)).addClass(BaseStepDefs.class);
verifyNoMoreInteractions(factory);
}
use of cucumber.runtime.io.ResourceLoader in project cucumber-jvm by cucumber.
the class CucumberFeatureTest method logs_message_if_no_feature_paths_are_given.
@Test
public void logs_message_if_no_feature_paths_are_given() {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ResourceLoader resourceLoader = mock(ResourceLoader.class);
CucumberFeature.load(resourceLoader, Collections.<String>emptyList(), emptyList(), new PrintStream(baos));
assertEquals(String.format("Got no path to feature directory or feature file%n"), baos.toString());
}
Aggregations