Debian Codegraph @

features/runner.select_scenarios_by_name.feature

raw
1 @sequential
2 Feature: Select named scenarios to run
3
4 As a tester
5 I want to select a subset of all scenarios
6 By using their name or parts of the scenario name.
7
8 . SPECIFICATION: When --name option is provided
9 . * Name selection is applied only to scenarios (currently)
10 . * A scenario is selected when scenario name part matches one of the provided names
11 . * Regular expressions can be used to match parts
12 . * If a scenario is not selected, it should be marked as skipped
13
14
15 @setup
16 Scenario: Test Setup
17 Given a new working directory
18 And a file named "features/steps/steps.py" with:
19 """
20 from behave import step
21
22 @step('a step passes')
23 def step_passes(context):
24 pass
25 """
26 And a file named "features/alice.feature" with:
27 """
28 Feature: Alice
29 Scenario: Alice in Wonderland
30 Given a step passes
31
32 Scenario: Alice in Florida
33 When a step passes
34
35 Scenario: Alice in Antarctica
36 Then a step passes
37 """
38 And a file named "features/bob.feature" with:
39 """
40 Feature: Bob
41 Scenario: Bob in Berlin
42 Given a step passes
43
44 Scenario: Bob in Florida
45 When a step passes
46
47 Scenario: Alice and Bob
48 Then a step passes
49 """
50 And a file named "behave.ini" with:
51 """
52 [behave]
53 show_skipped = false
54 show_timings = false
55 """
56
57 Scenario: Select scenarios with name="Alice" and inspect list
58 When I run "behave -f plain --name="Alice" --dry-run features/"
59 Then it should pass with:
60 """
61 0 features passed, 0 failed, 0 skipped, 2 untested
62 0 scenarios passed, 0 failed, 2 skipped, 4 untested
63 0 steps passed, 0 failed, 2 skipped, 0 undefined, 4 untested
64 """
65 And the command output should contain:
66 """
67 Feature: Alice
68 Scenario: Alice in Wonderland
69 Given a step passes ... untested
70 Scenario: Alice in Florida
71 When a step passes ... untested
72 Scenario: Alice in Antarctica
73 Then a step passes ... untested
74
75 Feature: Bob
76 Scenario: Alice and Bob
77 Then a step passes ... untested
78 """
79
80 Scenario: Select scenarios with name="Alice" and run them
81 When I run "behave -f plain -T --name="Alice" features/"
82 Then it should pass with:
83 """
84 2 features passed, 0 failed, 0 skipped
85 4 scenarios passed, 0 failed, 2 skipped
86 4 steps passed, 0 failed, 2 skipped, 0 undefined
87 """
88 And the command output should contain:
89 """
90 Feature: Alice
91 Scenario: Alice in Wonderland
92 Given a step passes ... passed
93 Scenario: Alice in Florida
94 When a step passes ... passed
95 Scenario: Alice in Antarctica
96 Then a step passes ... passed
97
98 Feature: Bob
99 Scenario: Alice and Bob
100 Then a step passes ... passed
101 """
102
103 Scenario: Select scenarios with name="Bob"
104 When I run "behave -f plain --name="Bob" --dry-run features/"
105 Then it should pass with:
106 """
107 0 features passed, 0 failed, 1 skipped, 1 untested
108 0 scenarios passed, 0 failed, 3 skipped, 3 untested
109 0 steps passed, 0 failed, 3 skipped, 0 undefined, 3 untested
110 """
111 And the command output should contain:
112 """
113 Feature: Bob
114 Scenario: Bob in Berlin
115 Given a step passes ... untested
116 Scenario: Bob in Florida
117 When a step passes ... untested
118 Scenario: Alice and Bob
119 Then a step passes ... untested
120 """
121
122 Scenario: Select scenarios with name="Florida"
123 When I run "behave -f plain --name="Florida" --dry-run features/"
124 Then it should pass with:
125 """
126 0 features passed, 0 failed, 0 skipped, 2 untested
127 0 scenarios passed, 0 failed, 4 skipped, 2 untested
128 0 steps passed, 0 failed, 4 skipped, 0 undefined, 2 untested
129 """
130 And the command output should contain:
131 """
132 Feature: Alice
133 Scenario: Alice in Florida
134 When a step passes ... untested
135
136 Feature: Bob
137 Scenario: Bob in Florida
138 When a step passes ... untested
139 """
140
141 Scenario: Select scenarios with name that consists of multiple words
142 When I run "behave -f plain --name="Alice and Bob" --dry-run features/"
143 Then it should pass with:
144 """
145 0 features passed, 0 failed, 1 skipped, 1 untested
146 0 scenarios passed, 0 failed, 5 skipped, 1 untested
147 """
148 And the command output should contain:
149 """
150 Feature: Bob
151 Scenario: Alice and Bob
152 """
153
154 Scenario: Select scenarios by using two names
155 When I run "behave -f plain --name="Alice" --name="Florida" --dry-run features/"
156 Then it should pass with:
157 """
158 0 features passed, 0 failed, 0 skipped, 2 untested
159 0 scenarios passed, 0 failed, 1 skipped, 5 untested
160 0 steps passed, 0 failed, 1 skipped, 0 undefined, 5 untested
161 """
162 And the command output should contain:
163 """
164 Feature: Alice
165 Scenario: Alice in Wonderland
166 Given a step passes ... untested
167 Scenario: Alice in Florida
168 When a step passes ... untested
169 Scenario: Alice in Antarctica
170 Then a step passes ... untested
171
172 Feature: Bob
173 Scenario: Bob in Florida
174 When a step passes ... untested
175 Scenario: Alice and Bob
176 Then a step passes ... untested
177 """
178
179 Scenario: Select scenarios by using a regular expression
180 When I run "behave -f plain --name="Alice in .*" --dry-run features/"
181 Then it should pass with:
182 """
183 0 features passed, 0 failed, 1 skipped, 1 untested
184 0 scenarios passed, 0 failed, 3 skipped, 3 untested
185 """
186 And the command output should contain:
187 """
188 Feature: Alice
189 Scenario: Alice in Wonderland
190 Given a step passes ... untested
191 Scenario: Alice in Florida
192 When a step passes ... untested
193 Scenario: Alice in Antarctica
194 Then a step passes ... untested
195 """
196 But the command output should not contain:
197 """
198 Scenario: Bob in
199 """
200
201 @not.with_os=win32
202 Scenario: Exclude scenarios by using a regular expression (not-pattern)
203
204 Select all scenarios that do not start with "Alice" in its name.
205 Exclude all scenarios that start with "Alice" in its name.
206 NOTE: Seems to work only for not-start-with idiom.
207
208 When I run "behave -f plain --name='^(?!Alice)' --dry-run features/"
209 Then it should pass with:
210 """
211 0 features passed, 0 failed, 1 skipped, 1 untested
212 0 scenarios passed, 0 failed, 4 skipped, 2 untested
213 """
214 And the command output should contain:
215 """
216 Feature: Bob
217 Scenario: Bob in Berlin
218 Given a step passes ... untested
219 Scenario: Bob in Florida
220 When a step passes ... untested
221 """
222 But the command output should not contain:
223 """
224 Scenario: Alice
225 """
226
227 Scenario: Select scenarios by using another regular expression
228 When I run "behave -f plain --name=".* in .*" --dry-run features/"
229 Then it should pass with:
230 """
231 0 features passed, 0 failed, 0 skipped, 2 untested
232 0 scenarios passed, 0 failed, 1 skipped, 5 untested
233 """
234 And the command output should contain:
235 """
236 Feature: Alice
237 Scenario: Alice in Wonderland
238 Given a step passes ... untested
239 Scenario: Alice in Florida
240 When a step passes ... untested
241 Scenario: Alice in Antarctica
242 Then a step passes ... untested
243
244 Feature: Bob
245 Scenario: Bob in Berlin
246 Given a step passes ... untested
247 Scenario: Bob in Florida
248 When a step passes ... untested
249 """
250 But the command output should not contain:
251 """
252 Scenario: Alice and Bob
253 """
254
255 Scenario: Select scenarios by using two regular expressions
256 When I run "behave -f plain --name="Alice in .*" --name="Bob in .*" --dry-run features/"
257 Then it should pass with:
258 """
259 0 features passed, 0 failed, 0 skipped, 2 untested
260 0 scenarios passed, 0 failed, 1 skipped, 5 untested
261 """
262 And the command output should contain:
263 """
264 Feature: Alice
265 Scenario: Alice in Wonderland
266 Given a step passes ... untested
267 Scenario: Alice in Florida
268 When a step passes ... untested
269 Scenario: Alice in Antarctica
270 Then a step passes ... untested
271
272 Feature: Bob
273 Scenario: Bob in Berlin
274 Given a step passes ... untested
275 Scenario: Bob in Florida
276 When a step passes ... untested
277 """
278 But the command output should not contain:
279 """
280 Scenario: Alice and Bob
281 """
282
283 Scenario: Select scenarios by using an unknown/unused name
284 When I run "behave -f plain --name="UNKNOWN" --dry-run features/"
285 Then it should pass with:
286 """
287 0 features passed, 0 failed, 2 skipped
288 0 scenarios passed, 0 failed, 6 skipped
289 """
290
291 Scenario: Select scenarios with special unicode names
292 Given a file named "features/xantippe.feature" with:
293 """
294 Feature: Use special unicode names
295
296 Scenario: Ärgernis is everywhere
297 Given a step passes
298
299 Scenario: Second Ärgernis
300 Then a step passes
301
302 Scenario: Something else
303 When a step passes
304 """
305 When I run "behave -f plain --name="Ärgernis" --dry-run features/xantippe.feature"
306 Then it should pass with:
307 """
308 0 features passed, 0 failed, 0 skipped, 1 untested
309 0 scenarios passed, 0 failed, 1 skipped, 2 untested
310 """
311 But the command output should not contain:
312 """
313 UnicodeDecodeError: 'ascii' codec can't decode byte
314 """