Add test for json correctly populating the description from a feature

This commit is contained in:
Jason Allen 2024-12-01 19:36:14 +00:00 committed by Alessio Bogon
parent be834076f3
commit 0efda3f87d
1 changed files with 19 additions and 18 deletions

View File

@ -51,6 +51,7 @@ def test_step_trace(pytester):
""" """
@feature-tag @feature-tag
Feature: One passing scenario, one failing scenario Feature: One passing scenario, one failing scenario
This is a feature description
@scenario-passing-tag @scenario-passing-tag
Scenario: Passing Scenario: Passing
@ -116,72 +117,72 @@ def test_step_trace(pytester):
assert result.ret assert result.ret
expected = [ expected = [
{ {
"description": "", "description": "This is a feature description",
"elements": [ "elements": [
{ {
"description": "", "description": "",
"id": "test_passing", "id": "test_passing",
"keyword": "Scenario", "keyword": "Scenario",
"line": 5, "line": 6,
"name": "Passing", "name": "Passing",
"steps": [ "steps": [
{ {
"keyword": "Given", "keyword": "Given",
"line": 6, "line": 7,
"match": {"location": ""}, "match": {"location": ""},
"name": "a passing step", "name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
}, },
{ {
"keyword": "And", "keyword": "And",
"line": 7, "line": 8,
"match": {"location": ""}, "match": {"location": ""},
"name": "some other passing step", "name": "some other passing step",
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
}, },
], ],
"tags": [{"name": "scenario-passing-tag", "line": 4}], "tags": [{"name": "scenario-passing-tag", "line": 5}],
"type": "scenario", "type": "scenario",
}, },
{ {
"description": "", "description": "",
"id": "test_failing", "id": "test_failing",
"keyword": "Scenario", "keyword": "Scenario",
"line": 10, "line": 11,
"name": "Failing", "name": "Failing",
"steps": [ "steps": [
{ {
"keyword": "Given", "keyword": "Given",
"line": 11, "line": 12,
"match": {"location": ""}, "match": {"location": ""},
"name": "a passing step", "name": "a passing step",
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
}, },
{ {
"keyword": "And", "keyword": "And",
"line": 12, "line": 13,
"match": {"location": ""}, "match": {"location": ""},
"name": "a failing step", "name": "a failing step",
"result": {"error_message": OfType(str), "status": "failed", "duration": OfType(int)}, "result": {"error_message": OfType(str), "status": "failed", "duration": OfType(int)},
}, },
], ],
"tags": [{"name": "scenario-failing-tag", "line": 9}], "tags": [{"name": "scenario-failing-tag", "line": 10}],
"type": "scenario", "type": "scenario",
}, },
{ {
"description": "", "description": "",
"keyword": "Scenario Outline", "keyword": "Scenario Outline",
"tags": [{"line": 14, "name": "scenario-outline-passing-tag"}], "tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
"steps": [ "steps": [
{ {
"line": 16, "line": 17,
"match": {"location": ""}, "match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given", "keyword": "Given",
"name": "type str and value hello", "name": "type str and value hello",
} }
], ],
"line": 15, "line": 16,
"type": "scenario", "type": "scenario",
"id": "test_passing_outline[str-hello]", "id": "test_passing_outline[str-hello]",
"name": "Passing outline", "name": "Passing outline",
@ -189,17 +190,17 @@ def test_step_trace(pytester):
{ {
"description": "", "description": "",
"keyword": "Scenario Outline", "keyword": "Scenario Outline",
"tags": [{"line": 14, "name": "scenario-outline-passing-tag"}], "tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
"steps": [ "steps": [
{ {
"line": 16, "line": 17,
"match": {"location": ""}, "match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given", "keyword": "Given",
"name": "type int and value 42", "name": "type int and value 42",
} }
], ],
"line": 15, "line": 16,
"type": "scenario", "type": "scenario",
"id": "test_passing_outline[int-42]", "id": "test_passing_outline[int-42]",
"name": "Passing outline", "name": "Passing outline",
@ -207,17 +208,17 @@ def test_step_trace(pytester):
{ {
"description": "", "description": "",
"keyword": "Scenario Outline", "keyword": "Scenario Outline",
"tags": [{"line": 14, "name": "scenario-outline-passing-tag"}], "tags": [{"line": 15, "name": "scenario-outline-passing-tag"}],
"steps": [ "steps": [
{ {
"line": 16, "line": 17,
"match": {"location": ""}, "match": {"location": ""},
"result": {"status": "passed", "duration": OfType(int)}, "result": {"status": "passed", "duration": OfType(int)},
"keyword": "Given", "keyword": "Given",
"name": "type float and value 1.0", "name": "type float and value 1.0",
} }
], ],
"line": 15, "line": 16,
"type": "scenario", "type": "scenario",
"id": "test_passing_outline[float-1.0]", "id": "test_passing_outline[float-1.0]",
"name": "Passing outline", "name": "Passing outline",