Skip to content

Commit e19288a

Browse files
jsa34youtux
authored andcommitted
Add missing scenario description in json
1 parent 0efda3f commit e19288a

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/pytest_bdd/cucumber_json.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def stepmap(step: dict[str, Any]) -> dict[str, Any]:
131131
"id": report.item["name"],
132132
"name": scenario["name"],
133133
"line": scenario["line_number"],
134-
"description": "",
134+
"description": scenario["description"],
135135
"tags": self._serialize_tags(scenario),
136136
"type": "scenario",
137137
"steps": [stepmap(step) for step in scenario["steps"]],

src/pytest_bdd/reporting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def serialize(self) -> dict[str, Any]:
113113
"name": scenario.name,
114114
"line_number": scenario.line_number,
115115
"tags": sorted(scenario.tags),
116+
"description": scenario.description,
116117
"feature": {
117118
"keyword": feature.keyword,
118119
"name": feature.name,

tests/feature/test_cucumber_json.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def test_step_trace(pytester):
5555
5656
@scenario-passing-tag
5757
Scenario: Passing
58+
This is a scenario description
59+
5860
Given a passing step
5961
And some other passing step
6062
@@ -120,22 +122,22 @@ def test_passing_outline():
120122
"description": "This is a feature description",
121123
"elements": [
122124
{
123-
"description": "",
125+
"description": "This is a scenario description",
124126
"id": "test_passing",
125127
"keyword": "Scenario",
126128
"line": 6,
127129
"name": "Passing",
128130
"steps": [
129131
{
130132
"keyword": "Given",
131-
"line": 7,
133+
"line": 9,
132134
"match": {"location": ""},
133135
"name": "a passing step",
134136
"result": {"status": "passed", "duration": OfType(int)},
135137
},
136138
{
137139
"keyword": "And",
138-
"line": 8,
140+
"line": 10,
139141
"match": {"location": ""},
140142
"name": "some other passing step",
141143
"result": {"status": "passed", "duration": OfType(int)},
@@ -148,77 +150,77 @@ def test_passing_outline():
148150
"description": "",
149151
"id": "test_failing",
150152
"keyword": "Scenario",
151-
"line": 11,
153+
"line": 13,
152154
"name": "Failing",
153155
"steps": [
154156
{
155157
"keyword": "Given",
156-
"line": 12,
158+
"line": 14,
157159
"match": {"location": ""},
158160
"name": "a passing step",
159161
"result": {"status": "passed", "duration": OfType(int)},
160162
},
161163
{
162164
"keyword": "And",
163-
"line": 13,
165+
"line": 15,
164166
"match": {"location": ""},
165167
"name": "a failing step",
166168
"result": {"error_message": OfType(str), "status": "failed", "duration": OfType(int)},
167169
},
168170
],
169-
"tags": [{"name": "scenario-failing-tag", "line": 10}],
171+
"tags": [{"name": "scenario-failing-tag", "line": 12}],
170172
"type": "scenario",
171173
},
172174
{
173175
"description": "",
174176
"keyword": "Scenario Outline",
175-
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
177+
"tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
176178
"steps": [
177179
{
178-
"line": 17,
180+
"line": 19,
179181
"match": {"location": ""},
180182
"result": {"status": "passed", "duration": OfType(int)},
181183
"keyword": "Given",
182184
"name": "type str and value hello",
183185
}
184186
],
185-
"line": 16,
187+
"line": 18,
186188
"type": "scenario",
187189
"id": "test_passing_outline[str-hello]",
188190
"name": "Passing outline",
189191
},
190192
{
191193
"description": "",
192194
"keyword": "Scenario Outline",
193-
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
195+
"tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
194196
"steps": [
195197
{
196-
"line": 17,
198+
"line": 19,
197199
"match": {"location": ""},
198200
"result": {"status": "passed", "duration": OfType(int)},
199201
"keyword": "Given",
200202
"name": "type int and value 42",
201203
}
202204
],
203-
"line": 16,
205+
"line": 18,
204206
"type": "scenario",
205207
"id": "test_passing_outline[int-42]",
206208
"name": "Passing outline",
207209
},
208210
{
209211
"description": "",
210212
"keyword": "Scenario Outline",
211-
"tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
213+
"tags": [{"line": 17, "name": "scenario-outline-passing-tag"}],
212214
"steps": [
213215
{
214-
"line": 17,
216+
"line": 19,
215217
"match": {"location": ""},
216218
"result": {"status": "passed", "duration": OfType(int)},
217219
"keyword": "Given",
218220
"name": "type float and value 1.0",
219221
}
220222
],
221-
"line": 16,
223+
"line": 18,
222224
"type": "scenario",
223225
"id": "test_passing_outline[float-1.0]",
224226
"name": "Passing outline",

0 commit comments

Comments
 (0)