Search in sources :

Example 6 with HookDefinition

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

HookDefinition (cucumber.runtime.HookDefinition)6 Test (org.junit.Test)5 Before (cucumber.api.java.Before)3 Tag (gherkin.formatter.model.Tag)3 After (cucumber.api.java.After)2 Scenario (cucumber.api.Scenario)1 Backend (cucumber.runtime.Backend)1 CucumberException (cucumber.runtime.CucumberException)1 Runtime (cucumber.runtime.Runtime)1 RuntimeOptions (cucumber.runtime.RuntimeOptions)1 StopWatch (cucumber.runtime.StopWatch)1 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)1 FunctionNameGenerator (cucumber.runtime.snippets.FunctionNameGenerator)1 Step (gherkin.formatter.model.Step)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1