File: issue0096.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 (173 lines) | stat: -rw-r--r-- 5,971 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
@issue
Feature: Issue #96: Sub-steps failed without any error info to help debug issue

    . I am trying to run execute_steps. One of them fails, but the error output
    . from behave has no details whatsoever. It is virtually impossible
    . to figure out why it failed. as no error output is present except the
    . final error message
    .
    .   def before_scenario(context,scenario):
    .       context.execute_steps(u'''
    .           When "admin:admin" sends POST "/tasks/testStart"
    .           Then I expect HTTP code 200
    .       ''')
    .
    . File ".../behave/runner.py", line 262, in execute_steps
    .  assert False, "FAILED SUB-STEP: %s" % step
    .  AssertionError: FAILED SUB-STEP: When "admin:admin" sends POST "/tasks/testStart"
    .
    .  All we get is the "sub-step failed" but no info whatsoever
    .  as to why it failed...



  Background:
    Given a new working directory
    And   a file named "features/steps/steps.py" with:
        """
        from behave import step
        import sys

        @step(u'a step passes')
        def step_passes(context):
            pass

        @step(u'a step fails')
        def step_fails(context):
            assert False, 'EXPECT: Step fails.'

        @step(u'a step fails with stdout "{message}"')
        def step_fails_with_stdout(context, message):
            sys.stdout.write("%s\n" % message)
            assert False, 'EXPECT: Step fails with stdout.'

        @step(u'a step fails with stderr "{message}"')
        def step_fails_with_stderr(context, message):
            sys.stderr.write("%s\n" % message)
            assert False, 'EXPECT: Step fails with stderr.'

        @step(u'a step raises an error "{message}"')
        def step_raises_exception(context, message):
            raise RuntimeError(message)

        @step(u'the following steps should pass')
        def step_following_steps_should_pass(context):
            context.execute_steps(context.text.strip())
        """

  Scenario: Execute steps and one fails (EXPECTATION-MISMATCH: Assert fails)
    Given a file named "features/issue96_case1.feature" with:
        '''
        Feature:
            Scenario:
                When the following steps should pass:
                   """
                   Given a step passes
                   When  a step fails
                   Then  a step passes
                   """
        '''
    When I run "behave -c features/issue96_case1.feature"
    Then it should fail with:
        """
        Assertion Failed: FAILED SUB-STEP: When a step fails
        Substep info: Assertion Failed: EXPECT: Step fails.
        """

  Scenario: Execute steps and error occurs (UNEXPECTED: exception is raised)
    Given a file named "features/issue96_case2.feature" with:
        '''
        Feature:
            Scenario:
                When the following steps should pass:
                   """
                   Given a step passes
                   When a step raises an error "Alice is alive"
                   Then a step passes
                   """
        '''
    When I run "behave -c features/issue96_case2.feature"
    Then it should fail with:
        """
        RuntimeError: Alice is alive
        """
    And the command output should contain:
        """
        Assertion Failed: FAILED SUB-STEP: When a step raises an error "Alice is alive"
        Substep info: Traceback (most recent call last):
        """

  Scenario: Execute steps and one fails with stdout capture
    Given a file named "features/issue96_case3.feature" with:
        '''
        Feature:
            Scenario:
                When the following steps should pass:
                   """
                   Given a step passes
                   When a step fails with stdout "STDOUT: Alice is alive"
                   Then a step passes
                   """
        '''
    When I run "behave -c features/issue96_case3.feature"
    Then it should fail with:
        """
        Assertion Failed: FAILED SUB-STEP: When a step fails with stdout "STDOUT: Alice is alive"
        Substep info: Assertion Failed: EXPECT: Step fails with stdout.
        """
    And the command output should contain:
        """
        Captured stdout:
        STDOUT: Alice is alive
        """


  Scenario: Execute steps and one fails with stderr capture
    Given a file named "features/issue96_case4.feature" with:
        '''
        Feature:
            Scenario:
                When the following steps should pass:
                   """
                   Given a step passes
                   When a step fails with stderr "STDERR: Alice is alive"
                   Then a step passes
                   """
        '''
    When I run "behave -c features/issue96_case4.feature"
    Then it should fail with:
        """
        Assertion Failed: FAILED SUB-STEP: When a step fails with stderr "STDERR: Alice is alive"
        Substep info: Assertion Failed: EXPECT: Step fails with stderr.
        """
    And the command output should contain:
        """
        Captured stderr:
        STDERR: Alice is alive
        """

  Scenario: Execute steps and fail in before_scenario hook
    Given a file named "features/issue96_case5.feature" with:
        """
        Feature:
            Scenario:
                Given a step passes
                When  a step passes
                Then  a step passes
        """
    And a file named "features/environment.py" with:
        """
        def before_scenario(context, scenario):
            context.execute_steps(u'''
               Given a step passes
               When a step passes
               Then a step fails
            ''')
        """
    When I run "behave -c features/issue96_case5.feature"
    Then it should fail with:
        """
        HOOK-ERROR in before_scenario: AssertionError: FAILED SUB-STEP: Then a step fails
        Substep info: Assertion Failed: EXPECT: Step fails.
        """