Search in sources :

Example 1 with MultiLoader

use of cucumber.runtime.io.MultiLoader 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;
}
Also used : ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) Ref(com.intellij.openapi.util.Ref) Runtime(cucumber.runtime.Runtime) MultiLoader(cucumber.runtime.io.MultiLoader) ArrayList(java.util.ArrayList) RuntimeOptions(cucumber.runtime.RuntimeOptions)

Example 2 with MultiLoader

use of cucumber.runtime.io.MultiLoader in project activityinfo by bedatadriven.

the class TestMain method queueUiTests.

private void queueUiTests() {
    ResourceLoader loader = new MultiLoader(getClass().getClassLoader());
    RuntimeOptions options = new RuntimeOptions(Arrays.asList("--tags", "@web", "classpath:org/activityinfo/test", "--glue", "org.activityinfo.test.steps.common", "--glue", "org.activityinfo.test.steps.web"));
    queueFeatures("ui", loader, options, new WebDriverModule(webDriverType));
    queueTestMethods("ui", new WebDriverModule(webDriverType));
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) WebDriverModule(org.activityinfo.test.webdriver.WebDriverModule) MultiLoader(cucumber.runtime.io.MultiLoader) RuntimeOptions(cucumber.runtime.RuntimeOptions)

Example 3 with MultiLoader

use of cucumber.runtime.io.MultiLoader 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();
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) Runtime(cucumber.runtime.Runtime) MultiLoader(cucumber.runtime.io.MultiLoader) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) ClassFinder(cucumber.runtime.ClassFinder) RuntimeOptions(cucumber.runtime.RuntimeOptions)

Example 4 with MultiLoader

use of cucumber.runtime.io.MultiLoader 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);
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) ObjectFactory(cucumber.api.java.ObjectFactory) Glue(cucumber.runtime.Glue) MultiLoader(cucumber.runtime.io.MultiLoader) Test(org.junit.Test)

Example 5 with MultiLoader

use of cucumber.runtime.io.MultiLoader in project activityinfo by bedatadriven.

the class ScenarioTestCase method createCucumberRuntime.

private Runtime createCucumberRuntime() {
    List<Module> moduleList = new ArrayList<>();
    moduleList.add(new ScenarioModule(new SequentialScenarioScope()));
    moduleList.addAll(testConditions.getModules());
    Injector injector = Guice.createInjector(moduleList);
    ClassLoader classLoader = getClass().getClassLoader();
    ResourceLoader resourceLoader = new MultiLoader(classLoader);
    ClassFinder classFinder = new ResourceLoaderClassFinder(resourceLoader, classLoader);
    JavaBackend backend = new JavaBackend(new GuiceObjectFactory(injector), classFinder);
    return new Runtime(resourceLoader, classLoader, Collections.singleton(backend), options);
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) JavaBackend(cucumber.runtime.java.JavaBackend) MultiLoader(cucumber.runtime.io.MultiLoader) ScenarioModule(cucumber.runtime.java.guice.impl.ScenarioModule) ArrayList(java.util.ArrayList) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) Runtime(cucumber.runtime.Runtime) Injector(com.google.inject.Injector) ResourceLoaderClassFinder(cucumber.runtime.io.ResourceLoaderClassFinder) ClassFinder(cucumber.runtime.ClassFinder) SequentialScenarioScope(cucumber.runtime.java.guice.impl.SequentialScenarioScope) Module(com.google.inject.Module) ScenarioModule(cucumber.runtime.java.guice.impl.ScenarioModule)

Aggregations

MultiLoader (cucumber.runtime.io.MultiLoader)8 ResourceLoader (cucumber.runtime.io.ResourceLoader)6 RuntimeOptions (cucumber.runtime.RuntimeOptions)5 ResourceLoaderClassFinder (cucumber.runtime.io.ResourceLoaderClassFinder)5 ClassFinder (cucumber.runtime.ClassFinder)3 Runtime (cucumber.runtime.Runtime)3 Module (com.google.inject.Module)2 ArrayList (java.util.ArrayList)2 ApiModule (org.activityinfo.test.driver.ApiModule)2 OdkModule (org.activityinfo.test.webdriver.OdkModule)2 WebDriverModule (org.activityinfo.test.webdriver.WebDriverModule)2 Injector (com.google.inject.Injector)1 Ref (com.intellij.openapi.util.Ref)1 ObjectFactory (cucumber.api.java.ObjectFactory)1 Glue (cucumber.runtime.Glue)1 JavaBackend (cucumber.runtime.java.JavaBackend)1 ScenarioModule (cucumber.runtime.java.guice.impl.ScenarioModule)1 SequentialScenarioScope (cucumber.runtime.java.guice.impl.SequentialScenarioScope)1 Method (java.lang.reflect.Method)1 EmailModule (org.activityinfo.test.driver.mail.EmailModule)1