| 1 |
Feature: Duplicated Step Definitions |
| 2 |
|
| 3 |
As I tester and test writer |
| 4 |
I want to know when step definitions are duplicated |
| 5 |
So that I can fix these problems. |
| 6 |
|
| 7 |
|
| 8 |
Scenario: Duplicated Step in same File |
| 9 |
Given a new working directory |
| 10 |
And a file named "features/steps/alice_steps.py" with: |
| 11 |
""" |
| 12 |
from behave import given, when, then |
| 13 |
|
| 14 |
@given(u'I call Alice') |
| 15 |
def step(context): |
| 16 |
pass |
| 17 |
|
| 18 |
@given(u'I call Alice') |
| 19 |
def step(context): |
| 20 |
pass |
| 21 |
""" |
| 22 |
And a file named "features/duplicated_step_alice.feature" with: |
| 23 |
""" |
| 24 |
Feature: |
| 25 |
Scenario: Duplicated Step |
| 26 |
Given I call Alice |
| 27 |
""" |
| 28 |
When I run "behave -f plain features/duplicated_step_alice.feature" |
| 29 |
Then it should fail |
| 30 |
And the command output should contain: |
| 31 |
""" |
| 32 |
AmbiguousStep: @given('I call Alice') has already been defined in |
| 33 |
existing step @given('I call Alice') at features/steps/alice_steps.py:3 |
| 34 |
""" |
| •35 |
# -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1). |
| 36 |
# And the command output should contain: |
| 37 |
# """ |
| 38 |
# File "features/steps/alice_steps.py", line 7, in <module> |
| 39 |
# """ |
| 40 |
|
| 41 |
|
| 42 |
Scenario: Duplicated Step Definition in another File |
| 43 |
Given a new working directory |
| 44 |
And a file named "features/steps/bob1_steps.py" with: |
| 45 |
""" |
| 46 |
from behave import given |
| 47 |
|
| 48 |
@given('I call Bob') |
| 49 |
def step_call_bob1(context): |
| 50 |
pass |
| 51 |
""" |
| 52 |
And a file named "features/steps/bob2_steps.py" with: |
| 53 |
""" |
| 54 |
from behave import given |
| 55 |
|
| 56 |
@given('I call Bob') |
| 57 |
def step_call_bob2(context): |
| 58 |
pass |
| 59 |
""" |
| 60 |
And a file named "features/duplicated_step_bob.feature" with: |
| 61 |
""" |
| 62 |
Feature: |
| 63 |
Scenario: Duplicated Step |
| 64 |
Given I call Bob |
| 65 |
""" |
| 66 |
When I run "behave -f plain features/duplicated_step_bob.feature" |
| 67 |
Then it should fail |
| 68 |
And the command output should contain: |
| 69 |
""" |
| 70 |
AmbiguousStep: @given('I call Bob') has already been defined in |
| 71 |
existing step @given('I call Bob') at features/steps/bob1_steps.py:3 |
| 72 |
""" |
| •73 |
# -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1). |
| 74 |
# And the command output should contain: |
| 75 |
# """ |
| 76 |
# File "features/steps/bob2_steps.py", line 3, in <module> |
| 77 |
# """ |
| 78 |
|
| 79 |
@xfail |
| 80 |
Scenario: Duplicated Same Step Definition via import from another File |
| 81 |
Given a new working directory |
| 82 |
And a file named "features/steps/charly1_steps.py" with: |
| 83 |
""" |
| 84 |
from behave import given |
| 85 |
|
| 86 |
@given('I call Charly') |
| 87 |
def step_call_charly1(context): |
| 88 |
pass |
| 89 |
""" |
| 90 |
And a file named "features/steps/charly2_steps.py" with: |
| 91 |
""" |
| 92 |
import charly1_steps |
| 93 |
""" |
| 94 |
And a file named "features/duplicated_step_via_import.feature" with: |
| 95 |
""" |
| 96 |
Feature: |
| 97 |
Scenario: Duplicated same step via import |
| 98 |
Given I call Charly |
| 99 |
""" |
| 100 |
When I run "behave -f plain features/duplicated_step_via_import.feature" |
| 101 |
Then it should pass |
| 102 |
And the command output should not contain: |
| 103 |
""" |
| 104 |
AmbiguousStep: @given('I call Charly') has already been defined in |
| 105 |
existing step @given('I call Charly') at features/steps/charly1_steps.py:3 |
| 106 |
""" |