Skip to content

Commit

Permalink
Add missing scenario description in json
Browse files Browse the repository at this point in the history
  • Loading branch information
jsa34 committed Dec 1, 2024
1 parent cb9983e commit c4d0451
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/pytest_bdd/cucumber_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def stepmap(step: dict[str, Any]) -> dict[str, Any]:
"id": report.item["name"],
"name": scenario["name"],
"line": scenario["line_number"],
"description": "",
"description": scenario["description"],
"tags": self._serialize_tags(scenario),
"type": "scenario",
"steps": [stepmap(step) for step in scenario["steps"]],
Expand Down
1 change: 1 addition & 0 deletions src/pytest_bdd/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def serialize(self) -> dict[str, Any]:
"name": scenario.name,
"line_number": scenario.line_number,
"tags": sorted(scenario.tags),
"description": scenario.description,
"feature": {
"keyword": feature.keyword,
"name": feature.name,
Expand Down
34 changes: 18 additions & 16 deletions tests/feature/test_cucumber_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def test_step_trace(pytester):
@scenario-passing-tag
Scenario: Passing
This is a scenario description
Given a passing step
And some other passing step
Expand Down Expand Up @@ -120,22 +122,22 @@ def test_passing_outline():
"description": "This is a feature description",
"elements": [
{
"description": "",
"description": "This is a scenario description",
"id": "test_passing",
"keyword": "Scenario",
"line": 6,
"name": "Passing",
"steps": [
{
"keyword": "Given",
"line": 7,
"line": 9,
"match": {"location": ""},
"name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)},
},
{
"keyword": "And",
"line": 8,
"line": 10,
"match": {"location": ""},
"name": "some other passing step",
"result": {"status": "passed", "duration": OfType(int)},
Expand All @@ -148,77 +150,77 @@ def test_passing_outline():
"description": "",
"id": "test_failing",
"keyword": "Scenario",
"line": 11,
"line": 13,
"name": "Failing",
"steps": [
{
"keyword": "Given",
"line": 12,
"line": 14,
"match": {"location": ""},
"name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)},
},
{
"keyword": "And",
"line": 13,
"line": 15,
"match": {"location": ""},
"name": "a failing step",
"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",
},
{
"description": "",
"keyword": "Scenario Outline",
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
"tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
"steps": [
{
"line": 17,
"line": 19,
"match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given",
"name": "type str and value hello",
}
],
"line": 16,
"line": 18,
"type": "scenario",
"id": "test_passing_outline[str-hello]",
"name": "Passing outline",
},
{
"description": "",
"keyword": "Scenario Outline",
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
"tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
"steps": [
{
"line": 17,
"line": 19,
"match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given",
"name": "type int and value 42",
}
],
"line": 16,
"line": 18,
"type": "scenario",
"id": "test_passing_outline[int-42]",
"name": "Passing outline",
},
{
"description": "",
"keyword": "Scenario Outline",
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
"tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
"steps": [
{
"line": 17,
"line": 19,
"match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given",
"name": "type float and value 1.0",
}
],
"line": 16,
"line": 18,
"type": "scenario",
"id": "test_passing_outline[float-1.0]",
"name": "Passing outline",
Expand Down

0 comments on commit c4d0451

Please sign in to comment.