-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathoutlines.feature
147 lines (116 loc) · 4.84 KB
/
outlines.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
Feature: Scenario outlines
Copying and pasting scenarios to use different values quickly
becomes tedious and repetitive. Scenario outlines allow us to more
concisely express these examples through the use of a template with
placeholders, using Scenario Outline, Examples with tables and < >
delimited parameters.
The Scenario Outline steps provide a template which is never directly
run. A Scenario Outline is run once for each row in the Examples section
beneath it (not counting the first row).
The way this works is via placeholders. Placeholders must be contained
within < > in the Scenario Outline's steps - see the examples below.
**IMPORTANT:** Your step definitions will never have to match a
placeholder. They will need to match the values that will replace the
placeholder.
Background:
Given a file named "features/outline_sample.feature" with:
"""
Feature: Outline Sample
Scenario Outline: Test state
Given <state> without a table
Given <other_state> without a table
Examples: Rainbow colours
| state | other_state |
| missing | passing |
| passing | passing |
| failing | passing |
Examples:Only passing
| state | other_state |
| passing | passing |
"""
And a file named "features/step_definitions/steps.rb" with:
"""
Given(/^passing without a table$/) { }
Given(/^failing without a table$/) { raise RuntimeError }
"""
Scenario: Run scenario outline
When I run `cucumber -q features/outline_sample.feature`
Then it should fail with:
"""
Feature: Outline Sample
Scenario Outline: Test state
Given <state> without a table
Given <other_state> without a table
Examples: Rainbow colours
| state | other_state |
| missing | passing |
| passing | passing |
| failing | passing |
RuntimeError (RuntimeError)
./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
features/outline_sample.feature:10:4:in `failing without a table'
Examples: Only passing
| state | other_state |
| passing | passing |
Failing Scenarios:
cucumber features/outline_sample.feature:10
4 scenarios (1 failed, 1 undefined, 2 passed)
8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
"""
Scenario: Run scenario with filtering on the scenario outline name
When I run `cucumber -q features/outline_sample.feature --name 'Test state'`
Then it should fail with:
"""
Feature: Outline Sample
Scenario Outline: Test state
Given <state> without a table
Given <other_state> without a table
Examples: Rainbow colours
| state | other_state |
| missing | passing |
| passing | passing |
| failing | passing |
RuntimeError (RuntimeError)
./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
features/outline_sample.feature:10:4:in `failing without a table'
Examples: Only passing
| state | other_state |
| passing | passing |
Failing Scenarios:
cucumber features/outline_sample.feature:10
4 scenarios (1 failed, 1 undefined, 2 passed)
8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
"""
Scenario: Run single failing scenario outline table row
When I run `cucumber -q features/outline_sample.feature:10`
Then it should fail with:
"""
Feature: Outline Sample
Scenario Outline: Test state
Given <state> without a table
Given <other_state> without a table
Examples: Rainbow colours
| state | other_state |
| failing | passing |
RuntimeError (RuntimeError)
./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
features/outline_sample.feature:10:4:in `failing without a table'
Failing Scenarios:
cucumber features/outline_sample.feature:10
1 scenario (1 failed)
2 steps (1 failed, 1 skipped)
"""
Scenario: Run all with progress formatter
When I run `cucumber -q --format progress features/outline_sample.feature`
Then it should fail with exactly:
"""
U-..F-..
(::) failed steps (::)
RuntimeError (RuntimeError)
./features/step_definitions/steps.rb:2:in `/^failing without a table$/'
features/outline_sample.feature:10:4:in `failing without a table'
Failing Scenarios:
cucumber features/outline_sample.feature:10
4 scenarios (1 failed, 1 undefined, 2 passed)
8 steps (1 failed, 2 skipped, 1 undefined, 4 passed)
"""