Skip to content

Commit

Permalink
Extend test_report with a skipping scenario
Browse files Browse the repository at this point in the history
- when a step is skipped the step should have skipped set to True
  • Loading branch information
dsax7 committed Jun 25, 2020
1 parent e6bfb7e commit e60130e
Showing 1 changed file with 73 additions and 15 deletions.
88 changes: 73 additions & 15 deletions tests/feature/test_report.py
Expand Up @@ -24,6 +24,7 @@ def test_step_trace(testdir):
feature-tag
scenario-passing-tag
scenario-failing-tag
scenario-skipping-tag
"""
),
)
Expand All @@ -32,7 +33,7 @@ def test_step_trace(testdir):
test=textwrap.dedent(
"""
@feature-tag
Feature: One passing scenario, one failing scenario
Feature: One passing scenario, one failing scenario, one skipping scenario
@scenario-passing-tag
Scenario: Passing
Expand All @@ -44,6 +45,12 @@ def test_step_trace(testdir):
Given a passing step
And a failing step
@scenario-skipping-tag
Scenario: Skipping
Given a passing step
And a skipping step
And a passing step
Scenario Outline: Outlined
Given there are <start> cucumbers
When I eat <eat> cucumbers
Expand Down Expand Up @@ -75,6 +82,10 @@ def some_other_passing_step():
def a_failing_step():
raise Exception('Error')
@given('a skipping step')
def a_skipping_step():
pytest.skip()
@given('there are <start> cucumbers')
def start_cucumbers(start):
assert isinstance(start, int)
Expand Down Expand Up @@ -106,7 +117,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"description": u"",
"filename": feature.strpath,
"line_number": 2,
"name": u"One passing scenario, one failing scenario",
"name": u"One passing scenario, one failing scenario, one skipping scenario",
"rel_filename": relpath,
"tags": [u"feature-tag"],
},
Expand Down Expand Up @@ -145,7 +156,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"description": u"",
"filename": feature.strpath,
"line_number": 2,
"name": u"One passing scenario, one failing scenario",
"name": u"One passing scenario, one failing scenario, one skipping scenario",
"rel_filename": relpath,
"tags": [u"feature-tag"],
},
Expand Down Expand Up @@ -177,24 +188,71 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
}
assert report == expected

report = result.matchreport("test_skipping", when="call").scenario
expected = {
"feature": {
"description": u"",
"filename": feature.strpath,
"line_number": 2,
"name": u"One passing scenario, one failing scenario, one skipping scenario",
"rel_filename": relpath,
"tags": [u"feature-tag"],
},
"line_number": 15,
"name": u"Skipping",
"steps": [
{
"duration": OfType(float),
"failed": False,
"keyword": "Given",
"line_number": 16,
"name": u"a passing step",
"skipped": False,
"type": "given",
},
{
"duration": OfType(float),
"failed": False,
"keyword": "And",
"line_number": 17,
"name": u"a skipping step",
"skipped": True,
"type": "given",
},
{
"duration": OfType(float),
"failed": False,
"keyword": "And",
"line_number": 18,
"name": u"a passing step",
"skipped": True,
"type": "given",
},
],
"tags": [u"scenario-skipping-tag"],
"examples": [],
"example_kwargs": {},
}
assert report == expected

report = result.matchreport("test_outlined[12-5.0-7]", when="call").scenario
expected = {
"feature": {
"description": u"",
"filename": feature.strpath,
"line_number": 2,
"name": u"One passing scenario, one failing scenario",
"name": u"One passing scenario, one failing scenario, one skipping scenario",
"rel_filename": relpath,
"tags": [u"feature-tag"],
},
"line_number": 14,
"line_number": 20,
"name": u"Outlined",
"steps": [
{
"duration": OfType(float),
"failed": False,
"keyword": "Given",
"line_number": 15,
"line_number": 21,
"name": u"there are <start> cucumbers",
"skipped": False,
"type": "given",
Expand All @@ -203,7 +261,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"duration": OfType(float),
"failed": False,
"keyword": "When",
"line_number": 16,
"line_number": 22,
"name": u"I eat <eat> cucumbers",
"skipped": False,
"type": "when",
Expand All @@ -212,7 +270,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"duration": OfType(float),
"failed": False,
"keyword": "Then",
"line_number": 17,
"line_number": 23,
"name": u"I should have <left> cucumbers",
"skipped": False,
"type": "then",
Expand All @@ -221,7 +279,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"tags": [],
"examples": [
{
"line_number": 19,
"line_number": 25,
"name": None,
"row_index": 0,
"rows": [["start", "eat", "left"], [[12, 5.0, "7"], [5, 4.0, "1"]]],
Expand All @@ -237,18 +295,18 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"description": u"",
"filename": feature.strpath,
"line_number": 2,
"name": u"One passing scenario, one failing scenario",
"name": u"One passing scenario, one failing scenario, one skipping scenario",
"rel_filename": relpath,
"tags": [u"feature-tag"],
},
"line_number": 14,
"line_number": 20,
"name": u"Outlined",
"steps": [
{
"duration": OfType(float),
"failed": False,
"keyword": "Given",
"line_number": 15,
"line_number": 21,
"name": u"there are <start> cucumbers",
"skipped": False,
"type": "given",
Expand All @@ -257,7 +315,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"duration": OfType(float),
"failed": False,
"keyword": "When",
"line_number": 16,
"line_number": 22,
"name": u"I eat <eat> cucumbers",
"skipped": False,
"type": "when",
Expand All @@ -266,7 +324,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"duration": OfType(float),
"failed": False,
"keyword": "Then",
"line_number": 17,
"line_number": 23,
"name": u"I should have <left> cucumbers",
"skipped": False,
"type": "then",
Expand All @@ -275,7 +333,7 @@ def should_have_left_cucumbers(start_cucumbers, start, eat, left):
"tags": [],
"examples": [
{
"line_number": 19,
"line_number": 25,
"name": None,
"row_index": 1,
"rows": [["start", "eat", "left"], [[12, 5.0, "7"], [5, 4.0, "1"]]],
Expand Down

0 comments on commit e60130e

Please sign in to comment.