Search in sources :

Example 1 with ScenarioModule

use of cucumber.runtime.java.guice.impl.ScenarioModule 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)

Example 2 with ScenarioModule

use of cucumber.runtime.java.guice.impl.ScenarioModule in project activityinfo by bedatadriven.

the class JUnitUiTestCase method call.

@Override
public TestResult call() throws Exception {
    List<Module> modules = Lists.newArrayList();
    modules.add(new ScenarioModule(new SequentialScenarioScope()));
    modules.addAll(testConditions.getModules());
    Injector injector = Guice.createInjector(modules);
    injector.getInstance(ScenarioScope.class).enterScope();
    WebDriverSession session = injector.getInstance(WebDriverSession.class);
    session.beforeTest(getId());
    Object testClassInstance = injector.getInstance(testMethod.getDeclaringClass());
    TestResult.Builder result = TestResult.builder(this);
    try {
        testMethod.invoke(testClassInstance);
    } catch (Throwable caught) {
        caught.printStackTrace();
        result.failed();
    } finally {
        result.output().append(TestOutputStream.drainThreadOutput());
        if (session.isRunning()) {
            session.stop();
        }
        injector.getInstance(ScenarioScope.class).exitScope();
    }
    return result.build();
}
Also used : WebDriverSession(org.activityinfo.test.webdriver.WebDriverSession) Injector(com.google.inject.Injector) ScenarioModule(cucumber.runtime.java.guice.impl.ScenarioModule) SequentialScenarioScope(cucumber.runtime.java.guice.impl.SequentialScenarioScope) ScenarioScope(cucumber.runtime.java.guice.ScenarioScope) SequentialScenarioScope(cucumber.runtime.java.guice.impl.SequentialScenarioScope) Module(com.google.inject.Module) ScenarioModule(cucumber.runtime.java.guice.impl.ScenarioModule)

Aggregations

Injector (com.google.inject.Injector)2 Module (com.google.inject.Module)2 ScenarioModule (cucumber.runtime.java.guice.impl.ScenarioModule)2 SequentialScenarioScope (cucumber.runtime.java.guice.impl.SequentialScenarioScope)2 ClassFinder (cucumber.runtime.ClassFinder)1 Runtime (cucumber.runtime.Runtime)1 MultiLoader (cucumber.runtime.io.MultiLoader)1 ResourceLoader (cucumber.runtime.io.ResourceLoader)1 ResourceLoaderClassFinder (cucumber.runtime.io.ResourceLoaderClassFinder)1 JavaBackend (cucumber.runtime.java.JavaBackend)1 ScenarioScope (cucumber.runtime.java.guice.ScenarioScope)1 ArrayList (java.util.ArrayList)1 WebDriverSession (org.activityinfo.test.webdriver.WebDriverSession)1