Commit ccf9c8e7 by Robert Buchholz

Make Step.behave_as fail when calling an undefined step

parent fed98379
...@@ -356,15 +356,15 @@ class Step(object): ...@@ -356,15 +356,15 @@ class Step(object):
for step in steps: for step in steps:
step.scenario = self.scenario step.scenario = self.scenario
(_, _, steps_failed, _, _) = self.run_all(steps) (_, _, steps_failed, steps_undefined, _) = self.run_all(steps)
if not steps_failed: if not steps_failed and not steps_undefined:
self.passed = True self.passed = True
self.failed = False self.failed = False
return self.passed return self.passed
else: self.passed = False
self.passed = False self.failed = True
self.failed = True assert not steps_failed, steps_failed[0].why.exception
assert not steps_failed, steps_failed[0].why.exception assert not steps_undefined, "Undefined step: %s" % steps_undefined[0].sentence
def run(self, ignore_case): def run(self, ignore_case):
"""Runs a step, trying to resolve it on available step """Runs a step, trying to resolve it on available step
......
...@@ -437,6 +437,30 @@ def test_failing_behave_as_step_fails(): ...@@ -437,6 +437,30 @@ def test_failing_behave_as_step_fails():
assert runnable_step.failed assert runnable_step.failed
@with_setup(step_runner_environ) @with_setup(step_runner_environ)
def test_undefined_behave_as_step_doesnt_pass():
'When a step definition calls an undefined step definition with behave_as, that step should not be marked as success.'
runnable_step = Step.from_string('Given I have a step which calls the "undefined step" step with behave_as')
try:
runnable_step.run(True)
assert False, "Undefined step should raise exception"
except:
pass
assert_false(runnable_step.passed)
@with_setup(step_runner_environ)
def test_undefined_behave_as_step_fails():
'When a step definition calls an undefined step definition with behave_as, that step should be marked a failure.'
runnable_step = Step.from_string('Given I have a step which calls the "undefined step" step with behave_as')
try:
runnable_step.run(True)
assert False, "Undefined step should raise exception"
except Exception, e:
pass
assert runnable_step.failed
@with_setup(step_runner_environ)
def test_failing_behave_as_step_raises_assertion(): def test_failing_behave_as_step_raises_assertion():
'When a step definition calls another (failing) step definition with behave_as, that step should be marked a failure.' 'When a step definition calls another (failing) step definition with behave_as, that step should be marked a failure.'
runnable_step = Step.from_string('Given I have a step which calls the "other step fails" step with behave_as') runnable_step = Step.from_string('Given I have a step which calls the "other step fails" step with behave_as')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment