Search in sources :

Example 1 with Backend

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;
}
Also used : JavaBackend(cucumber.runtime.java.JavaBackend) Backend(cucumber.runtime.Backend) JavaBackend(cucumber.runtime.java.JavaBackend) ObjectFactory(cucumber.api.java.ObjectFactory) ArrayList(java.util.ArrayList)

Example 2 with Backend

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);
}
Also used : ResourceLoader(cucumber.runtime.io.ResourceLoader) FileResourceLoader(cucumber.runtime.io.FileResourceLoader) JavaBackend(cucumber.runtime.java.JavaBackend) OsgiClassFinder(cucumber.java.runtime.osgi.OsgiClassFinder) Backend(cucumber.runtime.Backend) JavaBackend(cucumber.runtime.java.JavaBackend) Runtime(cucumber.runtime.Runtime) ObjectFactory(cucumber.api.java.ObjectFactory) PaxExamObjectFactory(cucumber.java.runtime.osgi.PaxExamObjectFactory) FileResourceLoader(cucumber.runtime.io.FileResourceLoader) PaxExamObjectFactory(cucumber.java.runtime.osgi.PaxExamObjectFactory) ClassFinder(cucumber.runtime.ClassFinder) OsgiClassFinder(cucumber.java.runtime.osgi.OsgiClassFinder) CucumberException(cucumber.runtime.CucumberException) RuntimeOptionsFactory(cucumber.runtime.RuntimeOptionsFactory) RuntimeOptions(cucumber.runtime.RuntimeOptions) Test(org.junit.Test)

Example 3 with Backend

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;
}
Also used : ArrayList(java.util.ArrayList) Step(gherkin.formatter.model.Step) Backend(cucumber.runtime.Backend) Runtime(cucumber.runtime.Runtime) FunctionNameGenerator(cucumber.runtime.snippets.FunctionNameGenerator) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) Runtime(cucumber.runtime.Runtime) File(java.io.File) RuntimeOptions(cucumber.runtime.RuntimeOptions)

Example 4 with Backend

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;
}
Also used : ArrayList(java.util.ArrayList) Step(gherkin.formatter.model.Step) StopWatch(cucumber.runtime.StopWatch) Backend(cucumber.runtime.Backend) Runtime(cucumber.runtime.Runtime) FunctionNameGenerator(cucumber.runtime.snippets.FunctionNameGenerator) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) Tag(gherkin.formatter.model.Tag) File(java.io.File) RuntimeOptions(cucumber.runtime.RuntimeOptions) HookDefinition(cucumber.runtime.HookDefinition)

Aggregations

Backend (cucumber.runtime.Backend)4 Runtime (cucumber.runtime.Runtime)3 RuntimeOptions (cucumber.runtime.RuntimeOptions)3 ArrayList (java.util.ArrayList)3 ObjectFactory (cucumber.api.java.ObjectFactory)2 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)2 JavaBackend (cucumber.runtime.java.JavaBackend)2 FunctionNameGenerator (cucumber.runtime.snippets.FunctionNameGenerator)2 Step (gherkin.formatter.model.Step)2 File (java.io.File)2 OsgiClassFinder (cucumber.java.runtime.osgi.OsgiClassFinder)1 PaxExamObjectFactory (cucumber.java.runtime.osgi.PaxExamObjectFactory)1 ClassFinder (cucumber.runtime.ClassFinder)1 CucumberException (cucumber.runtime.CucumberException)1 HookDefinition (cucumber.runtime.HookDefinition)1 RuntimeOptionsFactory (cucumber.runtime.RuntimeOptionsFactory)1 StopWatch (cucumber.runtime.StopWatch)1 FileResourceLoader (cucumber.runtime.io.FileResourceLoader)1 ResourceLoader (cucumber.runtime.io.ResourceLoader)1 Tag (gherkin.formatter.model.Tag)1