Add missing scenario description in json

This commit is contained in:
Jason Allen 2024-12-01 19:43:47 +00:00 committed by Alessio Bogon
parent 0efda3f87d
commit e19288ac07
3 changed files with 20 additions and 17 deletions

View File

@ -131,7 +131,7 @@ class LogBDDCucumberJSON:
"id": report.item["name"], "id": report.item["name"],
"name": scenario["name"], "name": scenario["name"],
"line": scenario["line_number"], "line": scenario["line_number"],
"description": "", "description": scenario["description"],
"tags": self._serialize_tags(scenario), "tags": self._serialize_tags(scenario),
"type": "scenario", "type": "scenario",
"steps": [stepmap(step) for step in scenario["steps"]], "steps": [stepmap(step) for step in scenario["steps"]],

View File

@ -113,6 +113,7 @@ class ScenarioReport:
"name": scenario.name, "name": scenario.name,
"line_number": scenario.line_number, "line_number": scenario.line_number,
"tags": sorted(scenario.tags), "tags": sorted(scenario.tags),
"description": scenario.description,
"feature": { "feature": {
"keyword": feature.keyword, "keyword": feature.keyword,
"name": feature.name, "name": feature.name,

View File

@ -55,6 +55,8 @@ def test_step_trace(pytester):
@scenario-passing-tag @scenario-passing-tag
Scenario: Passing Scenario: Passing
This is a scenario description
Given a passing step Given a passing step
And some other passing step And some other passing step
@ -120,7 +122,7 @@ def test_step_trace(pytester):
"description": "This is a feature description", "description": "This is a feature description",
"elements": [ "elements": [
{ {
"description": "", "description": "This is a scenario description",
"id": "test_passing", "id": "test_passing",
"keyword": "Scenario", "keyword": "Scenario",
"line": 6, "line": 6,
@ -128,14 +130,14 @@ def test_step_trace(pytester):
"steps": [ "steps": [
{ {
"keyword": "Given", "keyword": "Given",
"line": 7, "line": 9,
"match": {"location": ""}, "match": {"location": ""},
"name": "a passing step", "name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
}, },
{ {
"keyword": "And", "keyword": "And",
"line": 8, "line": 10,
"match": {"location": ""}, "match": {"location": ""},
"name": "some other passing step", "name": "some other passing step",
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
@ -148,41 +150,41 @@ def test_step_trace(pytester):
"description": "", "description": "",
"id": "test_failing", "id": "test_failing",
"keyword": "Scenario", "keyword": "Scenario",
"line": 11, "line": 13,
"name": "Failing", "name": "Failing",
"steps": [ "steps": [
{ {
"keyword": "Given", "keyword": "Given",
"line": 12, "line": 14,
"match": {"location": ""}, "match": {"location": ""},
"name": "a passing step", "name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
}, },
{ {
"keyword": "And", "keyword": "And",
"line": 13, "line": 15,
"match": {"location": ""}, "match": {"location": ""},
"name": "a failing step", "name": "a failing step",
"result": {"error_message": OfType(str), "status": "failed", "duration": OfType(int)}, "result": {"error_message": OfType(str), "status": "failed", "duration": OfType(int)},
}, },
], ],
"tags": [{"name": "scenario-failing-tag", "line": 10}], "tags": [{"name": "scenario-failing-tag", "line": 12}],
"type": "scenario", "type": "scenario",
}, },
{ {
"description": "", "description": "",
"keyword": "Scenario Outline", "keyword": "Scenario Outline",
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}], "tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
"steps": [ "steps": [
{ {
"line": 17, "line": 19,
"match": {"location": ""}, "match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given", "keyword": "Given",
"name": "type str and value hello", "name": "type str and value hello",
} }
], ],
"line": 16, "line": 18,
"type": "scenario", "type": "scenario",
"id": "test_passing_outline[str-hello]", "id": "test_passing_outline[str-hello]",
"name": "Passing outline", "name": "Passing outline",
@ -190,17 +192,17 @@ def test_step_trace(pytester):
{ {
"description": "", "description": "",
"keyword": "Scenario Outline", "keyword": "Scenario Outline",
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}], "tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
"steps": [ "steps": [
{ {
"line": 17, "line": 19,
"match": {"location": ""}, "match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given", "keyword": "Given",
"name": "type int and value 42", "name": "type int and value 42",
} }
], ],
"line": 16, "line": 18,
"type": "scenario", "type": "scenario",
"id": "test_passing_outline[int-42]", "id": "test_passing_outline[int-42]",
"name": "Passing outline", "name": "Passing outline",
@ -208,17 +210,17 @@ def test_step_trace(pytester):
{ {
"description": "", "description": "",
"keyword": "Scenario Outline", "keyword": "Scenario Outline",
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}], "tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
"steps": [ "steps": [
{ {
"line": 17, "line": 19,
"match": {"location": ""}, "match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given", "keyword": "Given",
"name": "type float and value 1.0", "name": "type float and value 1.0",
} }
], ],
"line": 16, "line": 18,
"type": "scenario", "type": "scenario",
"id": "test_passing_outline[float-1.0]", "id": "test_passing_outline[float-1.0]",
"name": "Passing outline", "name": "Passing outline",