use of cucumber.runtime.io.ResourceLoaderClassFinder in project intellij-community by JetBrains.
the class CucumberMain method run.
public static int run(final String[] argv, final ClassLoader classLoader) throws IOException {
final Ref<Throwable> errorRef = new Ref<>();
final Ref<Runtime> runtimeRef = new Ref<>();
try {
TestRunnerUtil.replaceIdeEventQueueSafely();
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
RuntimeOptions runtimeOptions = new RuntimeOptions(new ArrayList(Arrays.asList(argv)));
MultiLoader resourceLoader = new MultiLoader(classLoader);
ResourceLoaderClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
Runtime runtime = new Runtime(resourceLoader, classFinder, classLoader, runtimeOptions);
runtimeRef.set(runtime);
runtime.run();
} catch (Throwable throwable) {
errorRef.set(throwable);
Logger.getInstance(CucumberMain.class).error(throwable);
}
}
});
} catch (Throwable t) {
errorRef.set(t);
Logger.getInstance(CucumberMain.class).error(t);
}
final Throwable throwable = errorRef.get();
if (throwable != null) {
throwable.printStackTrace();
}
System.err.println("Failed tests :");
for (Throwable error : runtimeRef.get().getErrors()) {
error.printStackTrace();
System.err.println("=============================");
}
return throwable != null ? 1 : 0;
}
use of cucumber.runtime.io.ResourceLoaderClassFinder 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.ResourceLoaderClassFinder 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);
}
Aggregations