Skip to content

Commit 6eca0a3

Browse files
dsax7hristiy4n
authored andcommitted
Extend test_report with a skipping scenario
- when a step is skipped the step should have skipped set to True
1 parent 9529e46 commit 6eca0a3

File tree

1 file changed

+69
-13
lines changed

1 file changed

+69
-13
lines changed

tests/feature/test_report.py

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_step_trace(pytester):
2525
feature-tag
2626
scenario-passing-tag
2727
scenario-failing-tag
28+
scenario-skipping-tag
2829
"""
2930
),
3031
)
@@ -33,7 +34,7 @@ def test_step_trace(pytester):
3334
test=textwrap.dedent(
3435
"""
3536
@feature-tag
36-
Feature: One passing scenario, one failing scenario
37+
Feature: One passing scenario, one failing scenario, one skipping scenario
3738
3839
@scenario-passing-tag
3940
Scenario: Passing
@@ -45,6 +46,12 @@ def test_step_trace(pytester):
4546
Given a passing step
4647
And a failing step
4748
49+
@scenario-skipping-tag
50+
Scenario: Skipping
51+
Given a passing step
52+
And a skipping step
53+
And a passing step
54+
4855
Scenario Outline: Outlined
4956
Given there are <start> cucumbers
5057
When I eat <eat> cucumbers
@@ -76,6 +83,10 @@ def _():
7683
def _():
7784
raise Exception('Error')
7885
86+
@given('a skipping step')
87+
def _():
88+
pytest.skip()
89+
7990
@given(parsers.parse('there are {start:d} cucumbers'), target_fixture="cucumbers")
8091
def _(start):
8192
assert isinstance(start, int)
@@ -106,7 +117,7 @@ def _(cucumbers, left):
106117
"description": "",
107118
"filename": str(feature),
108119
"line_number": 2,
109-
"name": "One passing scenario, one failing scenario",
120+
"name": "One passing scenario, one failing scenario, one skipping scenario",
110121
"rel_filename": str(relpath),
111122
"tags": ["feature-tag"],
112123
},
@@ -143,7 +154,7 @@ def _(cucumbers, left):
143154
"description": "",
144155
"filename": str(feature),
145156
"line_number": 2,
146-
"name": "One passing scenario, one failing scenario",
157+
"name": "One passing scenario, one failing scenario, one skipping scenario",
147158
"rel_filename": str(relpath),
148159
"tags": ["feature-tag"],
149160
},
@@ -173,24 +184,69 @@ def _(cucumbers, left):
173184
}
174185
assert report == expected
175186

187+
report = result.matchreport("test_skipping", when="call").scenario
188+
expected = {
189+
"feature": {
190+
"description": "",
191+
"filename": str(feature),
192+
"line_number": 2,
193+
"name": "One passing scenario, one failing scenario, one skipping scenario",
194+
"rel_filename": str(relpath),
195+
"tags": ["feature-tag"],
196+
},
197+
"line_number": 15,
198+
"name": "Skipping",
199+
"steps": [
200+
{
201+
"duration": OfType(float),
202+
"failed": False,
203+
"keyword": "Given",
204+
"line_number": 16,
205+
"name": "a passing step",
206+
"skipped": False,
207+
"type": "given",
208+
},
209+
{
210+
"duration": OfType(float),
211+
"failed": False,
212+
"keyword": "And",
213+
"line_number": 17,
214+
"name": "a skipping step",
215+
"skipped": True,
216+
"type": "given",
217+
},
218+
{
219+
"duration": OfType(float),
220+
"failed": False,
221+
"keyword": "And",
222+
"line_number": 18,
223+
"name": "a passing step",
224+
"skipped": True,
225+
"type": "given",
226+
},
227+
],
228+
"tags": ["scenario-skipping-tag"],
229+
}
230+
assert report == expected
231+
176232
report = result.matchreport("test_outlined[12-5-7]", when="call").scenario
177233
expected = {
178234
"feature": {
179235
"description": "",
180236
"filename": str(feature),
181237
"line_number": 2,
182-
"name": "One passing scenario, one failing scenario",
238+
"name": "One passing scenario, one failing scenario, one skipping scenario",
183239
"rel_filename": str(relpath),
184240
"tags": ["feature-tag"],
185241
},
186-
"line_number": 14,
242+
"line_number": 20,
187243
"name": "Outlined",
188244
"steps": [
189245
{
190246
"duration": OfType(float),
191247
"failed": False,
192248
"keyword": "Given",
193-
"line_number": 15,
249+
"line_number": 21,
194250
"name": "there are 12 cucumbers",
195251
"skipped": False,
196252
"type": "given",
@@ -199,7 +255,7 @@ def _(cucumbers, left):
199255
"duration": OfType(float),
200256
"failed": False,
201257
"keyword": "When",
202-
"line_number": 16,
258+
"line_number": 22,
203259
"name": "I eat 5 cucumbers",
204260
"skipped": False,
205261
"type": "when",
@@ -208,7 +264,7 @@ def _(cucumbers, left):
208264
"duration": OfType(float),
209265
"failed": False,
210266
"keyword": "Then",
211-
"line_number": 17,
267+
"line_number": 23,
212268
"name": "I should have 7 cucumbers",
213269
"skipped": False,
214270
"type": "then",
@@ -224,18 +280,18 @@ def _(cucumbers, left):
224280
"description": "",
225281
"filename": str(feature),
226282
"line_number": 2,
227-
"name": "One passing scenario, one failing scenario",
283+
"name": "One passing scenario, one failing scenario, one skipping scenario",
228284
"rel_filename": str(relpath),
229285
"tags": ["feature-tag"],
230286
},
231-
"line_number": 14,
287+
"line_number": 20,
232288
"name": "Outlined",
233289
"steps": [
234290
{
235291
"duration": OfType(float),
236292
"failed": False,
237293
"keyword": "Given",
238-
"line_number": 15,
294+
"line_number": 21,
239295
"name": "there are 5 cucumbers",
240296
"skipped": False,
241297
"type": "given",
@@ -244,7 +300,7 @@ def _(cucumbers, left):
244300
"duration": OfType(float),
245301
"failed": False,
246302
"keyword": "When",
247-
"line_number": 16,
303+
"line_number": 22,
248304
"name": "I eat 4 cucumbers",
249305
"skipped": False,
250306
"type": "when",
@@ -253,7 +309,7 @@ def _(cucumbers, left):
253309
"duration": OfType(float),
254310
"failed": False,
255311
"keyword": "Then",
256-
"line_number": 17,
312+
"line_number": 23,
257313
"name": "I should have 1 cucumbers",
258314
"skipped": False,
259315
"type": "then",

0 commit comments

Comments
 (0)