From e60130e63279a543c388f3a9e6994f24e8b29e3c Mon Sep 17 00:00:00 2001 From: Hristiyan Ivanov Date: Thu, 25 Jun 2020 08:46:33 +0200 Subject: [PATCH] Extend test_report with a skipping scenario - when a step is skipped the step should have skipped set to True --- tests/feature/test_report.py | 88 ++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 15 deletions(-) diff --git a/tests/feature/test_report.py b/tests/feature/test_report.py index efb7996f..fe90baa5 100644 --- a/tests/feature/test_report.py +++ b/tests/feature/test_report.py @@ -24,6 +24,7 @@ def test_step_trace(testdir): feature-tag scenario-passing-tag scenario-failing-tag + scenario-skipping-tag """ ), ) @@ -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 @@ -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 cucumbers When I eat cucumbers @@ -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 cucumbers') def start_cucumbers(start): assert isinstance(start, int) @@ -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"], }, @@ -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"], }, @@ -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 cucumbers", "skipped": False, "type": "given", @@ -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 cucumbers", "skipped": False, "type": "when", @@ -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 cucumbers", "skipped": False, "type": "then", @@ -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"]]], @@ -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 cucumbers", "skipped": False, "type": "given", @@ -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 cucumbers", "skipped": False, "type": "when", @@ -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 cucumbers", "skipped": False, "type": "then", @@ -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"]]],