use of gherkin.formatter.JSONFormatter in project cucumber-jvm by cucumber.
the class RuntimeTest method runs_feature_with_json_formatter.
@Ignore
@Test
public void runs_feature_with_json_formatter() throws Exception {
CucumberFeature feature = feature("test.feature", "" + "Feature: feature name\n" + " Background: background name\n" + " Given b\n" + " Scenario: scenario name\n" + " When s\n");
StringBuilder out = new StringBuilder();
JSONFormatter jsonFormatter = new CucumberJSONFormatter(out);
List<Backend> backends = asList(mock(Backend.class));
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
RuntimeOptions runtimeOptions = new RuntimeOptions("");
Runtime runtime = new Runtime(new ClasspathResourceLoader(classLoader), classLoader, backends, runtimeOptions);
feature.run(jsonFormatter, jsonFormatter, runtime);
jsonFormatter.done();
String expected = "" + "[\n" + " {\n" + " \"id\": \"feature-name\",\n" + " \"description\": \"\",\n" + " \"name\": \"feature name\",\n" + " \"keyword\": \"Feature\",\n" + " \"line\": 1,\n" + " \"elements\": [\n" + " {\n" + " \"description\": \"\",\n" + " \"name\": \"background name\",\n" + " \"keyword\": \"Background\",\n" + " \"line\": 2,\n" + " \"steps\": [\n" + " {\n" + " \"result\": {\n" + " \"status\": \"undefined\"\n" + " },\n" + " \"name\": \"b\",\n" + " \"keyword\": \"Given \",\n" + " \"line\": 3,\n" + " \"match\": {}\n" + " }\n" + " ],\n" + " \"type\": \"background\"\n" + " },\n" + " {\n" + " \"id\": \"feature-name;scenario-name\",\n" + " \"description\": \"\",\n" + " \"name\": \"scenario name\",\n" + " \"keyword\": \"Scenario\",\n" + " \"line\": 4,\n" + " \"steps\": [\n" + " {\n" + " \"result\": {\n" + " \"status\": \"undefined\"\n" + " },\n" + " \"name\": \"s\",\n" + " \"keyword\": \"When \",\n" + " \"line\": 5,\n" + " \"match\": {}\n" + " }\n" + " ],\n" + " \"type\": \"scenario\"\n" + " }\n" + " ],\n" + " \"uri\": \"test.feature\"\n" + " }\n" + "]";
assertEquals(expected, out.toString());
}
Aggregations