File: issue0112.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 (64 lines) | stat: -rw-r--r-- 2,161 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
@issue
@change_request
Feature: Issue #112: Improvement to AmbiguousStep error

    . AmbiguousStep could be more useful if it also showed the existing string
    . with which the new one is clashing. This is particularly useful
    . if using step parameters.


  Background:
    Given a new working directory
    And   a file named "features/syndrome112.feature" with:
        """
        Feature:
          Scenario:
            Given I buy 10 oranges
        """

  Scenario: Good step ordering -- From specific to generic regular expression
    Given a file named "features/steps/good_steps.py" with:
        """
        from behave import given, when, then

        # -- ORDERING-IMPORTANT: From more specific steps to less specific.
        @given(u'I buy {number:n} {items:w}')
        def step_given_I_buy2(context, number, items):
            pass

        # -- OTHERWISE: Generic step matches all other patterns.
        @given(u'I buy {amount} {product}')
        def step_given_I_buy(context, amount, product):
            pass
        """
    When I run "behave -c features/syndrome112.feature"
    Then it should pass with:
        """
        1 feature passed, 0 failed, 0 skipped
        1 scenario passed, 0 failed, 0 skipped
        1 step passed, 0 failed, 0 skipped, 0 undefined
        """


  Scenario: Bad step ordering causes AmbiguousStep
    Given a file named "features/steps/bad_steps.py" with:
        """
        from behave import given, when, then

        # -- ORDERING-VIOLATED: Generic step comes first.
        @given(u'I buy {amount} {product}')
        def step_given_I_buy(context, amount, product):
            pass

        # -- AMBIGUOUS-STEP: Will occur here.
        @given(u'I buy {number:n} {items:w}')
        def step_given_I_buy2(context, number, items):
            pass
        """
    When I run "behave -c features/syndrome112.feature"
    Then it should fail
    And the command output should contain:
        """
        AmbiguousStep: @given('I buy {number:n} {items:w}') has already been defined in
          existing step @given('I buy {amount} {product}') at features/steps/bad_steps.py:4
        """