Search in sources :

Example 1 with CucumberJSONFormatter

use of cucumber.runtime.formatter.CucumberJSONFormatter 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());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) JSONFormatter(gherkin.formatter.JSONFormatter) CucumberJSONFormatter(cucumber.runtime.formatter.CucumberJSONFormatter) ClasspathResourceLoader(cucumber.runtime.io.ClasspathResourceLoader) CucumberJSONFormatter(cucumber.runtime.formatter.CucumberJSONFormatter) Matchers.anyString(org.mockito.Matchers.anyString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CucumberJSONFormatter (cucumber.runtime.formatter.CucumberJSONFormatter)1 ClasspathResourceLoader (cucumber.runtime.io.ClasspathResourceLoader)1 CucumberFeature (cucumber.runtime.model.CucumberFeature)1 JSONFormatter (gherkin.formatter.JSONFormatter)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1