forked from cucumber/cucumber-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexception_in_after_block.feature
128 lines (101 loc) · 3.79 KB
/
exception_in_after_block.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
Feature: Exception in After Block
In order to use custom assertions at the end of each scenario
As a developer
I want exceptions raised in After blocks to be handled gracefully and reported by the formatters
Background:
Given the standard step definitions
And a file named "features/step_definitions/naughty_steps.rb" with:
"""
Given /^this step does something naughty$/ do x=1
@naughty = true
end
"""
And a file named "features/support/env.rb" with:
"""
class NaughtyScenarioException < Exception; end
After do
if @naughty
raise NaughtyScenarioException.new("This scenario has been very very naughty")
end
end
"""
@spawn
Scenario: Handle Exception in standard scenario step and carry on
Given a file named "features/naughty_step_in_scenario.feature" with:
"""
Feature: Sample
Scenario: Naughty Step
Given this step does something naughty
Scenario: Success
Given this step passes
"""
When I run `cucumber features`
Then it should fail with:
"""
Feature: Sample
Scenario: Naughty Step # features/naughty_step_in_scenario.feature:3
Given this step does something naughty # features/step_definitions/naughty_steps.rb:1
This scenario has been very very naughty (NaughtyScenarioException)
./features/support/env.rb:4:in `After'
Scenario: Success # features/naughty_step_in_scenario.feature:6
Given this step passes # features/step_definitions/steps.rb:1
Failing Scenarios:
cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Naughty Step
2 scenarios (1 failed, 1 passed)
2 steps (2 passed)
"""
@spawn
@wip
Scenario: Handle Exception in scenario outline table row and carry on
Given a file named "features/naughty_step_in_scenario_outline.feature" with:
"""
Feature: Sample
Scenario Outline: Naughty Step
Given this step <Might Work>
Examples:
| Might Work |
| passes |
| does something naughty |
| passes |
Scenario: Success
Given this step passes
"""
When I run `cucumber features`
Then it should fail with:
"""
Feature: Sample
Scenario Outline: Naughty Step # features/naughty_step_in_scenario_outline.feature:3
Given this step <Might Work> # features/step_definitions/steps.rb:1
Examples:
| Might Work |
| passes |
| does something naughty |
This scenario has been very very naughty (NaughtyScenarioException)
./features/support/env.rb:4:in `After'
| passes |
Scenario: Success # features/naughty_step_in_scenario_outline.feature:12
Given this step passes # features/step_definitions/steps.rb:1
Failing Scenarios:
cucumber features/naughty_step_in_scenario_outline.feature:3 # Scenario: Naughty Step
4 scenarios (1 failed, 3 passed)
4 steps (4 passed)
"""
@wip
Scenario: Handle Exception using the progress format
Given a file named "features/naughty_step_in_scenario.feature" with:
"""
Feature: Sample
Scenario: Naughty Step
Given this step does something naughty
Scenario: Success
Given this step passes
"""
When I run `cucumber features --format progress`
Then it should fail with:
"""
.F.
Failing Scenarios:
cucumber features/naughty_step_in_scenario.feature:3 # Scenario: Naughty Step
2 scenarios (1 failed, 1 passed)
2 steps (2 passed)
"""