| 1 |
@issue |
| 2 |
Feature: Issue #42 Nice to have snippets for all unimplemented steps taking into account of the tags fltering |
| 3 |
|
| 4 |
As a user |
| 5 |
I want that all undefined steps are reported, |
| 6 |
not only just the first one in a scenario. |
| 7 |
|
| 8 |
In addition, all known steps after the first undefined step in a scenario |
| 9 |
should be marked as skipped (even failing ones). |
| 10 |
|
| 11 |
|
| 12 |
Background: Test Setup |
| 13 |
Given a new working directory |
| 14 |
And a file named "features/steps/steps.py" with: |
| 15 |
""" |
| 16 |
from behave import given, when, then |
| 17 |
|
| 18 |
@given(u'I enter a "{name}"') |
| 19 |
def step(context, name): |
| 20 |
context.name = name |
| 21 |
|
| 22 |
@when(u'I enter a "{name}"') |
| 23 |
def step(context, name): |
| 24 |
context.name = name |
| 25 |
|
| 26 |
@then(u'the name is "{name}"') |
| 27 |
def step(context, name): |
| 28 |
assert context.name == name |
| 29 |
""" |
| 30 |
|
| 31 |
Scenario: One undefined step in a scenario |
| 32 |
Given a file named "features/issue42_missing1.feature" with: |
| 33 |
""" |
| 34 |
Feature: Missing Given-Step in a Scenario |
| 35 |
Scenario: |
| 36 |
Given an unknown step |
| 37 |
When I enter a "Alice" |
| 38 |
Then the name is "Alice" |
| 39 |
""" |
| 40 |
When I run "behave -f plain features/issue42_missing1.feature" |
| 41 |
Then it should fail with: |
| 42 |
""" |
| 43 |
0 steps passed, 0 failed, 2 skipped, 1 undefined |
| 44 |
""" |
| 45 |
And the command output should contain: |
| 46 |
""" |
| 47 |
You can implement step definitions for undefined steps with these snippets: |
| 48 |
@given(u'an unknown step') |
| 49 |
def step_impl(context): |
| 50 |
raise NotImplementedError(u'STEP: Given an unknown step') |
| 51 |
""" |
| 52 |
|
| 53 |
Scenario: Two undefined steps in a scenario |
| 54 |
Given a file named "features/issue42_missing2.feature" with: |
| 55 |
""" |
| 56 |
Feature: Missing Given and When steps in a Scenario |
| 57 |
Scenario: |
| 58 |
Given an unknown step |
| 59 |
When another unknown step |
| 60 |
And I enter a "Alice" |
| 61 |
Then the name is "Alice" |
| 62 |
""" |
| 63 |
When I run "behave -f plain features/issue42_missing2.feature" |
| 64 |
Then it should fail with: |
| 65 |
""" |
| 66 |
0 steps passed, 0 failed, 2 skipped, 2 undefined |
| 67 |
""" |
| 68 |
And the command output should contain: |
| 69 |
""" |
| 70 |
You can implement step definitions for undefined steps with these snippets: |
| 71 |
@given(u'an unknown step') |
| 72 |
def step_impl(context): |
| 73 |
raise NotImplementedError(u'STEP: Given an unknown step') |
| 74 |
|
| 75 |
@when(u'another unknown step') |
| 76 |
def step_impl(context): |
| 77 |
raise NotImplementedError(u'STEP: When another unknown step') |
| 78 |
""" |
| 79 |
|
| 80 |
Scenario: Two undefined steps in the middle with passing steps |
| 81 |
Given a file named "features/issue42_missing3.feature" with: |
| 82 |
""" |
| 83 |
Feature: Missing 2 When steps after passing step |
| 84 |
Scenario: |
| 85 |
When I enter a "Alice" |
| 86 |
And an unknown step |
| 87 |
And another unknown step |
| 88 |
Then the name is "Alice" |
| 89 |
""" |
| 90 |
When I run "behave -f plain features/issue42_missing3.feature" |
| 91 |
Then it should fail with: |
| 92 |
""" |
| 93 |
1 step passed, 0 failed, 1 skipped, 2 undefined |
| 94 |
""" |
| 95 |
And the command output should contain: |
| 96 |
""" |
| 97 |
You can implement step definitions for undefined steps with these snippets: |
| 98 |
@when(u'an unknown step') |
| 99 |
def step_impl(context): |
| 100 |
raise NotImplementedError(u'STEP: When an unknown step') |
| 101 |
|
| 102 |
@when(u'another unknown step') |
| 103 |
def step_impl(context): |
| 104 |
raise NotImplementedError(u'STEP: When another unknown step') |
| 105 |
""" |
| 106 |
|
| 107 |
Scenario: Undefined steps are detected if they occur after a failing step |
| 108 |
Given a file named "features/issue42_missing4.feature" with: |
| 109 |
""" |
| 110 |
Feature: Missing 2 When steps after passing step |
| 111 |
Scenario: |
| 112 |
When I enter a "Alice" |
| 113 |
Then the name is "Bob" |
| 114 |
And an unknown step |
| 115 |
And another unknown step |
| 116 |
""" |
| 117 |
When I run "behave -f plain features/issue42_missing4.feature" |
| 118 |
Then it should fail with: |
| 119 |
""" |
| 120 |
1 step passed, 1 failed, 0 skipped, 2 undefined |
| 121 |
""" |
| 122 |
And the command output should contain: |
| 123 |
""" |
| 124 |
You can implement step definitions for undefined steps with these snippets: |
| 125 |
@then(u'an unknown step') |
| 126 |
def step_impl(context): |
| 127 |
raise NotImplementedError(u'STEP: Then an unknown step') |
| 128 |
|
| 129 |
@then(u'another unknown step') |
| 130 |
def step_impl(context): |
| 131 |
raise NotImplementedError(u'STEP: Then another unknown step') |
| 132 |
""" |
| 133 |
|
| 134 |
Scenario: Failing step after first undefined step should be marked as skipped |
| 135 |
Given a file named "features/issue42_missing4.feature" with: |
| 136 |
""" |
| 137 |
Feature: Missing 2 When steps after passing step |
| 138 |
Scenario: |
| 139 |
When I enter a "Alice" |
| 140 |
And an unknown step |
| 141 |
Then the name is "Bob" |
| 142 |
And another unknown step |
| 143 |
""" |
| 144 |
When I run "behave -f plain features/issue42_missing4.feature" |
| 145 |
Then it should fail with: |
| 146 |
""" |
| 147 |
1 step passed, 0 failed, 1 skipped, 2 undefined |
| 148 |
""" |
| 149 |
And the command output should contain: |
| 150 |
""" |
| 151 |
You can implement step definitions for undefined steps with these snippets: |
| 152 |
@when(u'an unknown step') |
| 153 |
def step_impl(context): |
| 154 |
raise NotImplementedError(u'STEP: When an unknown step') |
| 155 |
|
| 156 |
@then(u'another unknown step') |
| 157 |
def step_impl(context): |
| 158 |
raise NotImplementedError(u'STEP: Then another unknown step') |
| 159 |
""" |
| 160 |
|
| 161 |
Scenario: Two undefined steps in scenario outline |
| 162 |
Given a file named "features/issue42_missing5.feature" with: |
| 163 |
""" |
| 164 |
Feature: Missing Given and When Step in a Scenario Outline |
| 165 |
Scenario Outline: |
| 166 |
Given an unknown step |
| 167 |
When another unknown step |
| 168 |
And I enter a "<name>" |
| 169 |
Then the name is "<name>" |
| 170 |
|
| 171 |
Examples: |
| 172 |
|name | |
| 173 |
|Alice| |
| 174 |
|Bob | |
| 175 |
""" |
| 176 |
When I run "behave -f plain features/issue42_missing5.feature" |
| 177 |
Then it should fail with: |
| 178 |
""" |
| 179 |
0 steps passed, 0 failed, 4 skipped, 4 undefined |
| 180 |
""" |
| 181 |
And the command output should contain: |
| 182 |
""" |
| 183 |
You can implement step definitions for undefined steps with these snippets: |
| 184 |
@given(u'an unknown step') |
| 185 |
def step_impl(context): |
| 186 |
raise NotImplementedError(u'STEP: Given an unknown step') |
| 187 |
|
| 188 |
@when(u'another unknown step') |
| 189 |
def step_impl(context): |
| 190 |
raise NotImplementedError(u'STEP: When another unknown step') |
| 191 |
""" |
| 192 |
|
| 193 |
Scenario: Two undefined steps and run with tags |
| 194 |
Given a file named "features/issue42_missing6.feature" with: |
| 195 |
""" |
| 196 |
Feature: Missing steps in tagged scenarios |
| 197 |
@tag1 |
| 198 |
Scenario: |
| 199 |
When I enter a "Alice" |
| 200 |
And an unknown step |
| 201 |
Then the name is "Bob" |
| 202 |
|
| 203 |
@tag1 |
| 204 |
Scenario: |
| 205 |
When I enter a "Alice" |
| 206 |
And another unknown step |
| 207 |
Then the name is "Bob" |
| 208 |
|
| 209 |
@another_tag |
| 210 |
Scenario: |
| 211 |
When I enter a "Alice" |
| 212 |
And yet another unknown step |
| 213 |
Then the name is "Bob" |
| 214 |
""" |
| 215 |
When I run "behave -f plain --tags tag1 features/issue42_missing6.feature" |
| 216 |
Then it should fail with: |
| 217 |
""" |
| 218 |
2 steps passed, 0 failed, 5 skipped, 2 undefined |
| 219 |
""" |
| 220 |
And the command output should contain: |
| 221 |
""" |
| 222 |
You can implement step definitions for undefined steps with these snippets: |
| 223 |
@when(u'an unknown step') |
| 224 |
def step_impl(context): |
| 225 |
raise NotImplementedError(u'STEP: When an unknown step') |
| 226 |
|
| 227 |
@when(u'another unknown step') |
| 228 |
def step_impl(context): |
| 229 |
raise NotImplementedError(u'STEP: When another unknown step') |
| 230 |
""" |