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
|
@issue
Feature: Issue #127: Strip trailing colons
. Trailing colon in a step is stripped by the Gherkin parser.
. Undefined step snippets should not suggest the step with a trailing colon.
.
. GENERAL RULE (by looking at the parser):
. 1. Colon in step in feature file is OK
. (parser strips this for step-with-table or step-with-multiline-text).
. 2. Step definitions in Python files should not end with a colon
. (used in @given/@when/@then decorators).
Background:
Given a new working directory
And a file named "features/example127.feature" with:
"""
Feature:
Scenario:
Given the following superusers exist:
| Name | User Id |
| Alice | 101 |
| Bob | 102 |
"""
Scenario: Step Definition has no trailing colon (GOOD CASE)
Given a file named "features/steps/good_steps.py" with:
"""
from behave import given
@given(u'the following superusers exist')
def step_given_following_superusers_exist(context):
pass
"""
When I run "behave -f plain features/example127.feature"
Then it should pass
And the command output should not contain:
"""
You can implement step definitions for undefined steps with these snippets:
@given(u'the following superusers exist:')
def step_impl(context):
raise NotImplementedError(u'STEP: Given the following superusers exist:')
"""
Scenario: Step Definition has trailing colon (BAD CASE)
Given a file named "features/steps/bad_steps.py" with:
"""
from behave import given
@given(u'the following superusers exist:')
def step_given_following_superusers_exist(context):
pass
"""
When I run "behave -f plain features/example127.feature"
Then it should fail
And the command output should contain:
"""
You can implement step definitions for undefined steps with these snippets:
@given(u'the following superusers exist')
def step_impl(context):
raise NotImplementedError(u'STEP: Given the following superusers exist')
"""
|