forked from Behat/Behat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop_on_failure.feature
212 lines (171 loc) · 6.58 KB
/
stop_on_failure.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
Feature: Stop on failure
In order to stop further execution of steps when first step fails
As a feature developer
I need to have a --stop-on-failure option
Background:
Given a file named "features/bootstrap/FeatureContext.php" with:
"""
<?php
use Behat\Behat\Context\Context;
class FeatureContext implements Context
{
/**
* @Given /^I have (?:a|another) step that passes?$/
* @Then /^I should have a scenario that passed$/
*/
public function passing() {
}
/**
* @Given /^I have (?:a|another) step that fails?$/
* @Then /^I should have a scenario that failed$/
*/
public function failing() {
throw new Exception("step failed as supposed");
}
}
"""
And a file named "features/failing.feature" with:
"""
Feature: Failing Feature
In order to test the stop-on-failure feature
As a behat developer
I need to have a feature that fails
Background:
Given I have a step that passes
Scenario: 1st Passing
When I have a step that passes
Then I should have a scenario that passed
Scenario: 2nd Passing
When I have a step that passes
And I have another step that passes
Then I should have a scenario that passed
Scenario: 1st Failing
When I have a step that passes
And I have another step that fails
Then I should have a scenario that failed
Scenario: 2st Failing
When I have a step that fails
Then I should have a scenario that failed
"""
And a file named "features/missing-step.feature" with:
"""
Feature: Missing Step Feature
In order to test the stop-on-failure and strict features
As a behat developer
I need to have a feature with a missing step
Background:
Given I have a step that passes
Scenario: 1st Passing
When I have a step that passes
Then I should have a scenario that passed
Scenario: 2nd Passing
When I have a step that passes
And I have another step that passes
Then I should have a scenario that passed
Scenario: 1st Failing
When I have a step that passes
And I have another step that is missing
Then I should have a scenario that failed
Scenario: 2st Failing
When I have a step that is missing
Then I should have a scenario that failed
"""
And a file named "features/passing.feature" with:
"""
Feature: Passing Feature
In order to test the stop-on-failure feature
As a behat developer
I need to have a broken feature
Background:
Given I have a step that passes
Scenario: 1st Passing
When I have a step that passes
Then I should have a scenario that passed
Scenario: 2nd Passing
When I have a step that passes
And I have another step that passes
Then I should have a scenario that passed
Scenario: 3rd Passing
When I have a step that passes
And I have another step that passes
And I have another step that passes
Then I should have a scenario that passed
"""
Scenario: Just run feature
When I run "behat --no-colors --format-settings='{\"paths\": false}' --stop-on-failure features/failing.feature"
Then it should fail with:
"""
Feature: Failing Feature
In order to test the stop-on-failure feature
As a behat developer
I need to have a feature that fails
Background:
Given I have a step that passes
Scenario: 1st Passing
When I have a step that passes
Then I should have a scenario that passed
Scenario: 2nd Passing
When I have a step that passes
And I have another step that passes
Then I should have a scenario that passed
Scenario: 1st Failing
When I have a step that passes
And I have another step that fails
step failed as supposed (Exception)
Then I should have a scenario that failed
--- Failed scenarios:
features/failing.feature:18
3 scenarios (2 passed, 1 failed)
11 steps (9 passed, 1 failed, 1 skipped)
"""
Scenario: Just run feature
When I run "behat --no-colors --format-settings='{\"paths\": false}' --strict --stop-on-failure features/missing-step.feature"
Then it should fail with:
"""
Feature: Missing Step Feature
In order to test the stop-on-failure and strict features
As a behat developer
I need to have a feature with a missing step
Background:
Given I have a step that passes
Scenario: 1st Passing
When I have a step that passes
Then I should have a scenario that passed
Scenario: 2nd Passing
When I have a step that passes
And I have another step that passes
Then I should have a scenario that passed
Scenario: 1st Failing
When I have a step that passes
And I have another step that is missing
Then I should have a scenario that failed
3 scenarios (2 passed, 1 undefined)
11 steps (9 passed, 1 undefined, 1 skipped)
--- Use --snippets-for CLI option to generate snippets for following default suite steps:
And I have another step that is missing
"""
Scenario: Just run feature
When I run "behat --no-colors --format-settings='{\"paths\": false}' --stop-on-failure features/passing.feature"
Then it should pass with:
"""
Feature: Passing Feature
In order to test the stop-on-failure feature
As a behat developer
I need to have a broken feature
Background:
Given I have a step that passes
Scenario: 1st Passing
When I have a step that passes
Then I should have a scenario that passed
Scenario: 2nd Passing
When I have a step that passes
And I have another step that passes
Then I should have a scenario that passed
Scenario: 3rd Passing
When I have a step that passes
And I have another step that passes
And I have another step that passes
Then I should have a scenario that passed
3 scenarios (3 passed)
12 steps (12 passed)
"""