use of cucumber.runtime.Backend in project cucumber-jvm by cucumber.
the class CucumberExecutor method createBackends.
private Collection<? extends Backend> createBackends() {
final ObjectFactory delegateObjectFactory = ObjectFactoryLoader.loadObjectFactory(classFinder, Env.INSTANCE.get(ObjectFactory.class.getName()));
final AndroidObjectFactory objectFactory = new AndroidObjectFactory(delegateObjectFactory, instrumentation);
final List<Backend> backends = new ArrayList<Backend>();
backends.add(new JavaBackend(objectFactory, classFinder));
return backends;
}
use of cucumber.runtime.Backend in project cucumber-jvm by cucumber.
the class CalculatorTest method cucumber.
@Test
public void cucumber() throws Exception {
assertNotNull(injector);
assertNotNull(bundleContext);
final ResourceLoader resourceLoader = new FileResourceLoader();
final ClassLoader classLoader = Runtime.class.getClassLoader();
final ObjectFactory objectFactory = new PaxExamObjectFactory(injector);
final ClassFinder classFinder = new OsgiClassFinder(bundleContext);
final Backend backend = new JavaBackend(objectFactory, classFinder);
final RuntimeOptionsFactory runtimeOptionsFactory = new RuntimeOptionsFactory(getClass());
final RuntimeOptions runtimeOptions = runtimeOptionsFactory.create();
final Runtime runtime = new Runtime(resourceLoader, classLoader, Collections.singleton(backend), runtimeOptions);
runtime.run();
if (!runtime.getErrors().isEmpty()) {
throw new CucumberException(runtime.getErrors().get(0));
} else if (runtime.exitStatus() != 0x00) {
throw new CucumberException("There are pending or undefined steps.");
}
assertEquals(runtime.getErrors().size(), 0);
}
use of cucumber.runtime.Backend in project cucumber-jvm by cucumber.
the class JUnitFormatterTest method runFeaturesWithJunitFormatter.
private File runFeaturesWithJunitFormatter(final List<String> featurePaths, boolean strict) throws IOException {
File report = File.createTempFile("cucumber-jvm-junit", "xml");
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader(classLoader);
List<String> args = new ArrayList<String>();
if (strict) {
args.add("--strict");
}
args.add("--plugin");
args.add("junit:" + report.getAbsolutePath());
args.addAll(featurePaths);
RuntimeOptions runtimeOptions = new RuntimeOptions(args);
Backend backend = mock(Backend.class);
when(backend.getSnippet(any(Step.class), any(FunctionNameGenerator.class))).thenReturn("TEST SNIPPET");
final cucumber.runtime.Runtime runtime = new Runtime(resourceLoader, classLoader, asList(backend), runtimeOptions);
runtime.run();
return report;
}
use of cucumber.runtime.Backend in project cucumber-jvm by cucumber.
the class JSONPrettyFormatterTest method runFeaturesWithJSONPrettyFormatter.
private File runFeaturesWithJSONPrettyFormatter(final List<String> featurePaths) throws IOException {
HookDefinition hook = mock(HookDefinition.class);
when(hook.matches(anyListOf(Tag.class))).thenReturn(true);
File report = File.createTempFile("cucumber-jvm-junit", ".json");
final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
final ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader(classLoader);
List<String> args = new ArrayList<String>();
args.add("--plugin");
args.add("json:" + report.getAbsolutePath());
args.addAll(featurePaths);
RuntimeOptions runtimeOptions = new RuntimeOptions(args);
Backend backend = mock(Backend.class);
when(backend.getSnippet(any(Step.class), any(FunctionNameGenerator.class))).thenReturn("TEST SNIPPET");
final Runtime runtime = new Runtime(resourceLoader, classLoader, asList(backend), runtimeOptions, new StopWatch.Stub(1234), null);
runtime.getGlue().addBeforeHook(hook);
runtime.run();
return report;
}
Aggregations