Skip to content

Commit a050720

Browse files
committed
Extend test_report with a skipping scenario
- when a step is skipped the step should have skipped set to True
1 parent fa29345 commit a050720

File tree

1 file changed

+73
-15
lines changed

1 file changed

+73
-15
lines changed

tests/feature/test_report.py

+73-15
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def test_step_trace(testdir):
2424
feature-tag
2525
scenario-passing-tag
2626
scenario-failing-tag
27+
scenario-skipping-tag
2728
"""
2829
),
2930
)
@@ -32,7 +33,7 @@ def test_step_trace(testdir):
3233
test=textwrap.dedent(
3334
"""
3435
@feature-tag
35-
Feature: One passing scenario, one failing scenario
36+
Feature: One passing scenario, one failing scenario, one skipping scenario
3637
3738
@scenario-passing-tag
3839
Scenario: Passing
@@ -44,6 +45,12 @@ def test_step_trace(testdir):
4445
Given a passing step
4546
And a failing step
4647
48+
@scenario-skipping-tag
49+
Scenario: Skipping
50+
Given a passing step
51+
And a skipping step
52+
And a passing step
53+
4754
Scenario Outline: Outlined
4855
Given there are <start> cucumbers
4956
When I eat <eat> cucumbers
@@ -75,6 +82,10 @@ def some_other_passing_step():
7582
def a_failing_step():
7683
raise Exception('Error')
7784
85+
@given('a skipping step')
86+
def a_skipping_step():
87+
pytest.skip()
88+
7889
@given('there are <start> cucumbers')
7990
def start_cucumbers(start):
8091
assert isinstance(start, int)
@@ -106,7 +117,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
106117
"description": u"",
107118
"filename": feature.strpath,
108119
"line_number": 2,
109-
"name": u"One passing scenario, one failing scenario",
120+
"name": u"One passing scenario, one failing scenario, one skipping scenario",
110121
"rel_filename": relpath,
111122
"tags": [u"feature-tag"],
112123
},
@@ -145,7 +156,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
145156
"description": u"",
146157
"filename": feature.strpath,
147158
"line_number": 2,
148-
"name": u"One passing scenario, one failing scenario",
159+
"name": u"One passing scenario, one failing scenario, one skipping scenario",
149160
"rel_filename": relpath,
150161
"tags": [u"feature-tag"],
151162
},
@@ -177,24 +188,71 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
177188
}
178189
assert report == expected
179190

191+
report = result.matchreport("test_skipping", when="call").scenario
192+
expected = {
193+
"feature": {
194+
"description": u"",
195+
"filename": feature.strpath,
196+
"line_number": 2,
197+
"name": u"One passing scenario, one failing scenario, one skipping scenario",
198+
"rel_filename": relpath,
199+
"tags": [u"feature-tag"],
200+
},
201+
"line_number": 15,
202+
"name": u"Skipping",
203+
"steps": [
204+
{
205+
"duration": OfType(float),
206+
"failed": False,
207+
"keyword": "Given",
208+
"line_number": 16,
209+
"name": u"a passing step",
210+
"skipped": False,
211+
"type": "given",
212+
},
213+
{
214+
"duration": OfType(float),
215+
"failed": False,
216+
"keyword": "And",
217+
"line_number": 17,
218+
"name": u"a skipping step",
219+
"skipped": True,
220+
"type": "given",
221+
},
222+
{
223+
"duration": OfType(float),
224+
"failed": False,
225+
"keyword": "And",
226+
"line_number": 18,
227+
"name": u"a passing step",
228+
"skipped": True,
229+
"type": "given",
230+
},
231+
],
232+
"tags": [u"scenario-skipping-tag"],
233+
"examples": [],
234+
"example_kwargs": {},
235+
}
236+
assert report == expected
237+
180238
report = result.matchreport("test_outlined[12-5.0-7]", when="call").scenario
181239
expected = {
182240
"feature": {
183241
"description": u"",
184242
"filename": feature.strpath,
185243
"line_number": 2,
186-
"name": u"One passing scenario, one failing scenario",
244+
"name": u"One passing scenario, one failing scenario, one skipping scenario",
187245
"rel_filename": relpath,
188246
"tags": [u"feature-tag"],
189247
},
190-
"line_number": 14,
248+
"line_number": 20,
191249
"name": u"Outlined",
192250
"steps": [
193251
{
194252
"duration": OfType(float),
195253
"failed": False,
196254
"keyword": "Given",
197-
"line_number": 15,
255+
"line_number": 21,
198256
"name": u"there are <start> cucumbers",
199257
"skipped": False,
200258
"type": "given",
@@ -203,7 +261,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
203261
"duration": OfType(float),
204262
"failed": False,
205263
"keyword": "When",
206-
"line_number": 16,
264+
"line_number": 22,
207265
"name": u"I eat <eat> cucumbers",
208266
"skipped": False,
209267
"type": "when",
@@ -212,7 +270,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
212270
"duration": OfType(float),
213271
"failed": False,
214272
"keyword": "Then",
215-
"line_number": 17,
273+
"line_number": 23,
216274
"name": u"I should have <left> cucumbers",
217275
"skipped": False,
218276
"type": "then",
@@ -221,7 +279,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
221279
"tags": [],
222280
"examples": [
223281
{
224-
"line_number": 19,
282+
"line_number": 25,
225283
"name": None,
226284
"row_index": 0,
227285
"rows": [["start", "eat", "left"], [[12, 5.0, "7"], [5, 4.0, "1"]]],
@@ -237,18 +295,18 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
237295
"description": u"",
238296
"filename": feature.strpath,
239297
"line_number": 2,
240-
"name": u"One passing scenario, one failing scenario",
298+
"name": u"One passing scenario, one failing scenario, one skipping scenario",
241299
"rel_filename": relpath,
242300
"tags": [u"feature-tag"],
243301
},
244-
"line_number": 14,
302+
"line_number": 20,
245303
"name": u"Outlined",
246304
"steps": [
247305
{
248306
"duration": OfType(float),
249307
"failed": False,
250308
"keyword": "Given",
251-
"line_number": 15,
309+
"line_number": 21,
252310
"name": u"there are <start> cucumbers",
253311
"skipped": False,
254312
"type": "given",
@@ -257,7 +315,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
257315
"duration": OfType(float),
258316
"failed": False,
259317
"keyword": "When",
260-
"line_number": 16,
318+
"line_number": 22,
261319
"name": u"I eat <eat> cucumbers",
262320
"skipped": False,
263321
"type": "when",
@@ -266,7 +324,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
266324
"duration": OfType(float),
267325
"failed": False,
268326
"keyword": "Then",
269-
"line_number": 17,
327+
"line_number": 23,
270328
"name": u"I should have <left> cucumbers",
271329
"skipped": False,
272330
"type": "then",
@@ -275,7 +333,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
275333
"tags": [],
276334
"examples": [
277335
{
278-
"line_number": 19,
336+
"line_number": 25,
279337
"name": None,
280338
"row_index": 1,
281339
"rows": [["start", "eat", "left"], [[12, 5.0, "7"], [5, 4.0, "1"]]],

0 commit comments

Comments
 (0)