Search in sources :

Example 6 with RuntimeOptions

use of cucumber.runtime.RuntimeOptions 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

Runtime (cucumber.runtime.Runtime)6 RuntimeOptions (cucumber.runtime.RuntimeOptions)6 Backend (cucumber.runtime.Backend)3 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)3 ArrayList (java.util.ArrayList)3 ClassFinder (cucumber.runtime.ClassFinder)2 StopWatch (cucumber.runtime.StopWatch)2 MultiLoader (cucumber.runtime.io.MultiLoader)2 ResourceLoader (cucumber.runtime.io.ResourceLoader)2 ResourceLoaderClassFinder (cucumber.runtime.io.ResourceLoaderClassFinder)2 FunctionNameGenerator (cucumber.runtime.snippets.FunctionNameGenerator)2 Step (gherkin.formatter.model.Step)2 File (java.io.File)2 Ref (com.intellij.openapi.util.Ref)1 ObjectFactory (cucumber.api.java.ObjectFactory)1 OsgiClassFinder (cucumber.java.runtime.osgi.OsgiClassFinder)1 PaxExamObjectFactory (cucumber.java.runtime.osgi.PaxExamObjectFactory)1 CucumberException (cucumber.runtime.CucumberException)1 HookDefinition (cucumber.runtime.HookDefinition)1 RuntimeGlue (cucumber.runtime.RuntimeGlue)1