Commit 344bbb07 by Gabriel Falcao

fixing the behave_as feature. closes #135

parent ede8a9b4
# language: en
Feature: Multiplication
In order to avoid silly mistakes
Cashiers must be able to multiplicate numbers :)
Scenario: Regular numbers
Given I have entered 10 into the calculator
And I have entered 4 into the calculator
When I press multiply
Then the result should be 40 on the screen
Scenario: Shorter version of the scenario above
Given I multiply 10 and 4 into the calculator
Then the result should be 40 on the screen
# -*- coding: utf-8 -*-
from nose.tools import assert_equals
from lettuce import step, world, before
@before.each_scenario
def set_stack_and_result(scenario):
world.stack = []
world.result = 0
@step(u'I have entered (\d+) into the calculator')
def i_have_entered_NUM_into_the_calculator(step, num):
world.stack.append(num)
assert False, 'Die, die, die my darling!'
@step(u'I press multiply')
def i_press_multiply(step):
world.result = reduce(lambda x, y: x*y, map(int, world.stack))
@step(u'the result should be (\d+) on the screen')
def the_result_should_be_NUM_on_the_screen(step, num):
assert_equals(world.result, int(num))
@step(u'I multiply (\d+) and (\d+) into the calculator')
def multiply_X_and_Y_into_the_calculator(step, x, y):
step.behave_as('''
I have entered {0} into the calculator
And I have entered {1} into the calculator
And I press multiply
'''.format(x, y))
......@@ -77,3 +77,41 @@ def test_simple_tables_behave_as_feature():
"4 steps (4 passed)\n"
)
@with_setup(prepare_stdout)
def test_failing_tables_behave_as_feature():
"Basic step.behave_as behaviour is working"
Runner(path_to_feature('3rd_failing_steps'), verbosity=3).run()
assert_stdout_lines(
'\n'
'Feature: Multiplication # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:2\n'
' In order to avoid silly mistakes # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:3\n'
' Cashiers must be able to multiplicate numbers :) # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:4\n'
'\n'
' Scenario: Regular numbers # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:6\n'
' Given I have entered 10 into the calculator # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:11\n'
' Traceback (most recent call last):\n'
' File "/Users/gabrielfalcao/Projetos/lettuce/lettuce/core.py", line 113, in __call__\n'
' ret = self.function(self.step, *args, **kw)\n'
' File "/Users/gabrielfalcao/Projetos/lettuce/tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py", line 13, in i_have_entered_NUM_into_the_calculator\n'
' assert False, \'Die, die, die my darling!\'\n'
' AssertionError: Die, die, die my darling!\n'
' And I have entered 4 into the calculator # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:11\n'
' When I press multiply # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:16\n'
' Then the result should be 40 on the screen # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:20\n'
'\n'
' Scenario: Shorter version of the scenario above # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:12\n'
' Given I multiply 10 and 4 into the calculator # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:24\n'
' Traceback (most recent call last):\n'
' File "/Users/gabrielfalcao/Projetos/lettuce/lettuce/core.py", line 113, in __call__\n'
' ret = self.function(self.step, *args, **kw)\n'
' File "/Users/gabrielfalcao/Projetos/lettuce/tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py", line 29, in multiply_X_and_Y_into_the_calculator\n'
' \'\'\'.format(x, y))\n'
' File "/Users/gabrielfalcao/Projetos/lettuce/lettuce/core.py", line 366, in behave_as\n'
' assert not steps_failed, steps_failed[0].why.exception\n'
' AssertionError: Die, die, die my darling!\n'
' Then the result should be 40 on the screen # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:20\n'
'\n'
'1 feature (0 passed)\n'
'2 scenarios (0 passed)\n'
'6 steps (2 failed, 4 skipped, 0 passed)\n'
)
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