use of cucumber.runtime.java.guice.impl.SequentialScenarioScope 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);
}
use of cucumber.runtime.java.guice.impl.SequentialScenarioScope 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();
}
Aggregations