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
|
@issue
Feature: Issue #83: behave.__main__:main() Various sys.exit issues
. Currently, the main function has several issues related
. to sys.exit() returncode usage:
.
. 1. sys.exit("string") is invalid, a number must be used:
. => Used in exception cases after run (ParseError, ConfigError)
.
. 2. On success, the main() function returns implicitly None
. instead of using sys.exit(0)
. => No statement at end of function after failed case.
@setup
Scenario: Feature Setup
Given a new working directory
And a file named "features/steps/steps.py" with:
"""
from behave import step
@step(u'a step passes')
def step_passes(context):
pass
"""
Scenario: Successful test run
Given a file named "features/passing.feature" with:
"""
Feature:
Scenario:
Given a step passes
When a step passes
Then a step passes
"""
When I run "behave -c features/passing.feature"
Then it should pass
And the command returncode is "0"
Scenario: ParseError occurs
Given a file named "features/invalid_with_ParseError.feature" with:
"""
Feature:
Scenario: Invalid scenario which raises ParseError
Given a step passes
When2 a step passes
"""
When I run "behave -c features/invalid_with_ParseError.feature"
Then it should fail
And the command returncode is non-zero
And the command output should contain:
"""
Failed to parse "{__WORKDIR__}/features/invalid_with_ParseError.feature"
"""
Scenario: ConfigError occurs
Given a new working directory
And a file named "features/passing2.feature" with:
"""
Feature:
Scenario:
Given a step passes
"""
When I run "behave -c features/passing2.feature"
Then it should fail
And the command returncode is non-zero
And the command output should contain:
"""
No steps directory in '{__WORKDIR__}/features'
"""
|