File: step.duplicated_step.feature

package info (click to toggle)
behave 1.2.6-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,160 kB
  • sloc: python: 19,857; makefile: 137; sh: 18
file content (106 lines) | stat: -rw-r--r-- 3,297 bytes parent folder | download | duplicates (3)
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
Feature: Duplicated Step Definitions

  As I tester and test writer
  I want to know when step definitions are duplicated
  So that I can fix these problems.


  Scenario: Duplicated Step in same File
    Given a new working directory
    And a file named "features/steps/alice_steps.py" with:
      """
      from behave import given, when, then

      @given(u'I call Alice')
      def step(context):
          pass

      @given(u'I call Alice')
      def step(context):
          pass
      """
    And a file named "features/duplicated_step_alice.feature" with:
      """
      Feature:
        Scenario: Duplicated Step
          Given I call Alice
      """
    When I run "behave -f plain features/duplicated_step_alice.feature"
    Then it should fail
    And the command output should contain:
        """
        AmbiguousStep: @given('I call Alice') has already been defined in
        existing step @given('I call Alice') at features/steps/alice_steps.py:3
        """
    # -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1).
    # And the command output should contain:
    #    """
    #    File "features/steps/alice_steps.py", line 7, in <module>
    #    """


  Scenario: Duplicated Step Definition in another File
    Given a new working directory
    And a file named "features/steps/bob1_steps.py" with:
      """
      from behave import given

      @given('I call Bob')
      def step_call_bob1(context):
          pass
      """
    And   a file named "features/steps/bob2_steps.py" with:
      """
      from behave import given

      @given('I call Bob')
      def step_call_bob2(context):
          pass
      """
    And a file named "features/duplicated_step_bob.feature" with:
      """
      Feature:
        Scenario: Duplicated Step
          Given I call Bob
      """
    When I run "behave -f plain features/duplicated_step_bob.feature"
    Then it should fail
    And the command output should contain:
        """
        AmbiguousStep: @given('I call Bob') has already been defined in
        existing step @given('I call Bob') at features/steps/bob1_steps.py:3
        """
    # -- DISABLED: Python 3.8 traceback line numbers differ w/ decorators (+1).
    # And the command output should contain:
    #    """
    #    File "features/steps/bob2_steps.py", line 3, in <module>
    #    """

  @xfail
  Scenario: Duplicated Same Step Definition via import from another File
    Given a new working directory
    And a file named "features/steps/charly1_steps.py" with:
      """
      from behave import given

      @given('I call Charly')
      def step_call_charly1(context):
          pass
      """
    And   a file named "features/steps/charly2_steps.py" with:
      """
      import charly1_steps
      """
    And a file named "features/duplicated_step_via_import.feature" with:
      """
      Feature:
        Scenario: Duplicated same step via import
          Given I call Charly
      """
    When I run "behave -f plain features/duplicated_step_via_import.feature"
    Then it should pass
    And the command output should not contain:
        """
        AmbiguousStep: @given('I call Charly') has already been defined in
        existing step @given('I call Charly') at features/steps/charly1_steps.py:3
        """