Debian Codegraph @

features/step_dialect.generic_steps.feature

raw
1 Feature: Step dialect for generic steps
2
3 As a test/story writer
4 I want to have a possibility to use generic steps
5 So that I can execute a sequence of steps without BDD keywords (Given/When/Then)
6
7 . SPECIFICATION: Generic step
8 . * Prefix each step with a '*' (asterisk/star) character to mark it as step
9 . * Provide step-functions/step definition with "@step" decorator
10
11
12 @setup
13 Scenario: Feature Setup
14 Given a new working directory
15 And a file named "features/steps/steps.py" with:
16 """
17 from behave import step
18
19 @step('{word:w} step passes')
20 def step_passes(context, word):
21 pass
22
23 @step('{word:w} step passes with "{param}"')
24 def step_passes_with_param(context, word, param):
25 pass
26
27 @step('a multi-line text step with')
28 def step_with_multiline_text(context):
29 assert context.text is not None, "REQUIRE: multi-line text"
30
31 @step('a step fails with "{param}"')
32 def step_fails_with_param(context, param=None):
33 assert False, "XFAIL-STEP: %s" % param
34
35 @step('a step fails')
36 def step_fails(context):
37 assert False, "XFAIL-STEP"
38
39 @step('a table step with')
40 def step_with_table(context):
41 assert context.table, "REQUIRES: table"
42 context.table.require_columns(["name", "age"])
43 """
44
45
46 Scenario: Simple step-by-step example
47
48 * a step passes
49 * another step passes
50
51
52 Scenario: Simple step-by-step example 2
53 Given a file named "features/generic_steps.feature" with:
54 """
55 Feature:
56 Scenario:
57 * a step passes
58 * another step passes
59 * a step passes with "Alice"
60 * another step passes with "Bob"
61 """
62 When I run "behave -f plain -T features/generic_steps.feature"
63 Then it should pass with:
64 """
65 1 scenario passed, 0 failed, 0 skipped
66 4 steps passed, 0 failed, 0 skipped
67 """
68 And the command output should contain:
69 """
70 Feature:
71 Scenario:
72 * a step passes ... passed
73 * another step passes ... passed
74 * a step passes with "Alice" ... passed
75 * another step passes with "Bob" ... passed
76 """
77
78 Scenario: Simple step-by-step example with failing steps
79 Given a file named "features/generic_steps.failing.feature" with:
80 """
81 Feature:
82 Scenario:
83 * a step passes
84 * a step fails with "Alice"
85 * a step fails with "Bob"
86 * another step passes
87 """
88 When I run "behave -f plain -T features/generic_steps.failing.feature"
89 Then it should fail with:
90 """
91 0 scenarios passed, 1 failed, 0 skipped
92 1 step passed, 1 failed, 2 skipped
93 """
94 And the command output should contain:
95 """
96 Feature:
97 Scenario:
98 * a step passes ... passed
99 * a step fails with "Alice" ... failed
100 """
101
102
103 Scenario: Simple step-by-step example with scenario description
104
105 CASE: Ensure that first step is discovered after last description line.
106
107 Given a file named "features/generic_steps.with_description.feature" with:
108 '''
109 Feature:
110 Scenario:
111
112 First scenario description line.
113 Second scenario description line.
114
115 * a step passes
116 * another step passes
117 '''
118 When I run "behave -f plain -T features/generic_steps.with_description.feature"
119 Then it should pass with:
120 """
121 1 scenario passed, 0 failed, 0 skipped
122 2 steps passed, 0 failed, 0 skipped
123 """
124
125
126 Scenario: Simple step-by-step example with multi-line text
127 Given a file named "features/generic_steps.with_text.feature" with:
128 '''
129 Feature:
130 Scenario:
131 * a step passes
132 * a multi-line text step with:
133 """
134 First line of multi-line text.
135 Second-line of multi-line text.
136 """
137 * another step passes with "Charly"
138 '''
139 When I run "behave -f plain -T features/generic_steps.with_text.feature"
140 Then it should pass with:
141 """
142 1 scenario passed, 0 failed, 0 skipped
143 3 steps passed, 0 failed, 0 skipped
144 """
145 And the command output should contain:
146 '''
147 Feature:
148
149 Scenario:
150 * a step passes ... passed
151 * a multi-line text step with ... passed
152 """
153 First line of multi-line text.
154 Second-line of multi-line text.
155 """
156 * another step passes with "Charly" ... passed
157 '''
158
159 Scenario: Simple step-by-step example with table
160 Given a file named "features/generic_steps.with_table.feature" with:
161 '''
162 Feature:
163 Scenario:
164 * a step passes
165 * a table step with:
166 | name | age |
167 | Alice | 10 |
168 | Bob | 12 |
169 * another step passes with "Dodo"
170 '''
171 When I run "behave -f plain -T features/generic_steps.with_table.feature"
172 Then it should pass with:
173 """
174 1 scenario passed, 0 failed, 0 skipped
175 3 steps passed, 0 failed, 0 skipped
176 """
177 And the command output should contain:
178 '''
179 Feature:
180 Scenario:
181 * a step passes ... passed
182 * a table step with ... passed
183 | name | age |
184 | Alice | 10 |
185 | Bob | 12 |
186 * another step passes with "Dodo" ... passed
187 '''
188
189