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("--format");
    args.add("json:" + report.getAbsolutePath());
    args.addAll(featurePaths);

    RuntimeOptions runtimeOptions =
        new RuntimeOptions(new Properties(), args.toArray(new String[args.size()]));
    Backend backend = mock(Backend.class);
    when(backend.getSnippet(any(Step.class), any(FunctionNameSanitizer.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;
  }
Ejemplo n.º 2
0
 @Before
 public void buildMockWorld() {
   ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
   RuntimeOptions runtimeOptions = new RuntimeOptions(new Properties());
   runtime =
       new Runtime(
           mock(ResourceLoader.class), classLoader, asList(mock(Backend.class)), runtimeOptions);
   runtime.buildBackendWorlds(null);
   glue = runtime.getGlue();
 }