Skip to content

cucumber-core: Use the docstring content type in the json formatter. #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ private Map<String, Object> createDocStringMap(Argument argument) {
PickleString docString = ((PickleString)argument);
docStringMap.put("value", docString.getContent());
docStringMap.put("line", docString.getLocation().getLine());
docStringMap.put("content_type", docString.getContentType());
return docStringMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,68 @@ public void should_format_scenario_with_a_step_with_a_doc_string() throws Throwa
assertPrettyJsonEquals(expected, formatterOutput);
}

@Test
public void should_format_scenario_with_a_step_with_a_doc_string2() throws Throwable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest should_format_scenario_with_a_step_with_a_doc_string_and_content_type

CucumberFeature feature = TestHelper.feature("path/test.feature", "" +
"Feature: Banana party\n" +
"\n" +
" Scenario: Monkey eats bananas\n" +
" Given there are bananas\n" +
" \"\"\"doc\n" +
" doc string content\n" +
" \"\"\"\n");
Map<String, Result> stepsToResult = new HashMap<String, Result>();
stepsToResult.put("there are bananas", result("passed"));
Map<String, String> stepsToLocation = new HashMap<String, String>();
stepsToLocation.put("there are bananas", "StepDefs.there_are_bananas()");
Long stepDuration = milliSeconds(1);

String formatterOutput = runFeatureWithJSONPrettyFormatter(feature, stepsToResult, stepsToLocation, stepDuration);

String expected = "[\n" +
" {\n" +
" \"line\": 1,\n" +
" \"elements\": [\n" +
" {\n" +
" \"line\": 3,\n" +
" \"name\": \"Monkey eats bananas\",\n" +
" \"description\": \"\",\n" +
" \"id\": \"banana-party;monkey-eats-bananas\",\n" +
" \"type\": \"scenario\",\n" +
" \"keyword\": \"Scenario\",\n" +
" \"steps\": [\n" +
" {\n" +
" \"result\": {\n" +
" \"duration\": 1000000,\n" +
" \"status\": \"passed\"\n" +
" },\n" +
" \"line\": 4,\n" +
" \"name\": \"there are bananas\",\n" +
" \"match\": {\n" +
" \"location\": \"StepDefs.there_are_bananas()\"\n" +
" },\n" +
" \"keyword\": \"Given \",\n" +
" \"doc_string\": {\n" +
" \"content_type\": \"doc\",\n" +
" \"line\": 5,\n" +
" \"value\": \"doc string content\"\n" +
" }\n" +
" }\n" +
" ]\n" +
" }\n" +
" ],\n" +
" \"name\": \"Banana party\",\n" +
" \"description\": \"\",\n" +
" \"id\": \"banana-party\",\n" +
" \"keyword\": \"Feature\",\n" +
" \"uri\": \"path/test.feature\"\n" +
" }\n" +
"]";

assertPrettyJsonEquals(expected, formatterOutput);
}


@Test
public void should_format_scenario_with_a_step_with_a_data_table() throws Throwable {
CucumberFeature feature = TestHelper.feature("path/test.feature", "" +
Expand Down