Debian Codegraph @

features/scenario.description.feature

raw
1 Feature: Scenario Description
2
3 As a tester
4 I want to explain the rationale of a test scenario or scenario outline
5 Before I actually execute the steps.
6
7 . SPECIFICATION: Scenario Description
8 . * Scenario descriptions are in optional section between
9 . Scenario line and the first step.
10 . * All description lines are added to the scenario description.
11 . * Empty lines are not part of the scenario description (are removed).
12 . * Comment lines are not part of the scenario description (are removed).
13 . * A Scenario/ScenarioOutline with a scenario description,
14 . but without steps is valid (to support preparation of scenarios).
15 .
16 . SPECIFICATION: A scenario description line...
17 . * must not start with step keywords, like:
18 .
19 . Given, When, Then, And, But, etc.
20 . (including lower-case versions)
21 .
22 . * must not start with '*' (ASTERISK) due to generic step keyword ambiguity
23 . * must not start with '@' (AT) due to tag ambiguity
24 . (supporting: scenario without steps but with step description).
25 . * may start with '|' (table-cell-separator).
26 . * does not contain only whitespace chars (empty line, filtered-out).
27 . * does not start with '#' (HASH) after whitespace chars (comment line).
28 .
29 . GRAMMAR STRUCTURE:
30 . Scenario-Line : 1
31 . Scenario-Description-Line : 0 .. N
32 . Step-Line : 0 .. N
33 .
34 . Scenario-Line := Scenario-Keyword ':' Scenario-Name
35 . Scenario-Description-Line := Line does not start with Step-Keyword
36 . Step-Line := Step-Keyword Words+
37
38
39 @setup
40 Scenario: Feature Setup
41 Given a new working directory
42 And a file named "features/steps/steps.py" with:
43 """
44 from behave import step
45 import sys
46
47 @step('a step passes')
48 def step_passes(context):
49 pass
50
51 @step('a step passes with "{comment}"')
52 def step_passes(context, comment):
53 sys.stdout.write("PASSING-STEP: %s;\n" % comment)
54
55 @step('a step fails')
56 def step_fails(context):
57 assert False, "XFAIL-STEP"
58 """
59
60
61 Scenario: First Example for a Scenario Description
62 Given a file named "features/example_description1.feature" with:
63 """
64 Feature:
65 Scenario: E1
66
67 This is a simple scenario description before the steps start.
68 It explains why this scenario is important.
69
70 Here another scenario description line after an empty line.
71
72 Given a step passes with "Alice"
73 When a step passes with "Bob"
74 Then a step passes with "Charly"
75 """
76 When I run "behave -f plain -T features/example_description1.feature"
77 Then it should pass with:
78 """
79 1 feature passed, 0 failed, 0 skipped
80 1 scenario passed, 0 failed, 0 skipped
81 3 steps passed, 0 failed, 0 skipped, 0 undefined
82 """
83 And the command output should contain:
84 """
85 Feature:
86 Scenario: E1
87 Given a step passes with "Alice" ... passed
88 When a step passes with "Bob" ... passed
89 Then a step passes with "Charly" ... passed
90 """
91
92
93 Scenario: Inspect the Scenario Description by using JSON
94 Given a file named "features/example_description1.feature" exists
95 When I run "behave -f json.pretty -o example1.json -f plain -T features/example_description1.feature"
96 Then it should pass
97 And the file "example1.json" should contain:
98 """
99 "description": [
100 "This is a simple scenario description before the steps start.",
101 "It explains why this scenario is important.",
102 "Here another scenario description line after an empty line."
103 ],
104 "keyword": "Scenario",
105 "location": "features/example_description1.feature:2",
106 "name": "E1",
107 """
108
109
110 Scenario: Second Example with 2 scenario with scenario descriptions
111 Given a file named "features/example_description2.feature" with:
112 """
113 @one
114 Feature: F2
115
116 Feature description line 1.
117 Feature description line 2.
118
119 @foo
120 Scenario: S2.1
121
122 Scenario description line S2.1-1.
123 Scenario description line S2.1-2 (indentation is removed).
124
125 Given a step passes with "Alice"
126 Then a step passes with "Charly"
127
128 @foo
129 @bar @baz
130 Scenario: S2.2
131
132 Scenario description line S2.2-1.
133
134 When a step passes with "Bob"
135 """
136 When I run "behave -f json.pretty -o example2.json -f plain -T features/example_description2.feature"
137 Then it should pass with:
138 """
139 1 feature passed, 0 failed, 0 skipped
140 2 scenarios passed, 0 failed, 0 skipped
141 3 steps passed, 0 failed, 0 skipped, 0 undefined
142 """
143 And the command output should contain:
144 """
145 Feature: F2
146 Scenario: S2.1
147 Given a step passes with "Alice" ... passed
148 Then a step passes with "Charly" ... passed
149
150 Scenario: S2.2
151 When a step passes with "Bob" ... passed
152 """
153 And the file "example2.json" should contain:
154 """
155 "description": [
156 "Scenario description line S2.1-1.",
157 "Scenario description line S2.1-2 (indentation is removed)."
158 ],
159 "keyword": "Scenario",
160 "location": "features/example_description2.feature:8",
161 "name": "S2.1",
162 """
163 And the file "example2.json" should contain:
164 """
165 "description": [
166 "Scenario description line S2.2-1."
167 ],
168 "keyword": "Scenario",
169 "location": "features/example_description2.feature:18",
170 "name": "S2.2",
171 """