Skip to content

Unclear semantic of Examples tables with overlapped parameters #481

@elchupanebrej

Description

@elchupanebrej

When I execute Feature:

Feature: Outline

    Examples:
    | start | eat | left |
    |  12   |  11 |  1   |
    |   5   |  4  |  1   |


    Scenario Outline: Outlined given, when, thens
        Given there are <start> <fruits>
        When I eat <eat> <fruits>
        Then I should have <left> <fruits>

        Examples:
        | fruits  | left |
        | apples  |  7   |
        | oranges |  3   |

I expect that scenario will fail at collection time because some examples names are used twice and have no overlapping values, but the scenario is started to execute and drops values from Feature examples:

________________________ test_outline[12-11-7-apples] _________________________

request = <FixtureRequest for <Function test_outline[12-11-7-apples]>>
_pytest_bdd_example = {'eat': '11', 'fruits': 'apples', 'left': '7', 'start': '12'}

    @pytest.mark.usefixtures(*args)
    def scenario_wrapper(request, _pytest_bdd_example):
        scenario = templated_scenario.render(_pytest_bdd_example)
>       _execute_scenario(feature, scenario, request)

C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:174: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:144: in _execute_scenario
    _execute_step_function(request, scenario, step, step_func)
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:114: in _execute_step_function
    return_value = step_func(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

start_fruits = {'apples': {'eat': 11.0, 'start': 12}}, start = 12, eat = 11.0
left = '7', fruits = 'apples'

    @then(parsers.parse("I should have {left} {fruits}"))
    def should_have_left_fruits(start_fruits, start, eat, left, fruits):
        dump_obj(left, fruits)
    
        assert isinstance(left, str)
>       assert start - eat == int(left)
E       AssertionError: assert (12 - 11.0) == 7
E        +  where 7 = int('7')

test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py:32: AssertionError
________________________ test_outline[12-11-3-oranges] ________________________

request = <FixtureRequest for <Function test_outline[12-11-3-oranges]>>
_pytest_bdd_example = {'eat': '11', 'fruits': 'oranges', 'left': '3', 'start': '12'}

    @pytest.mark.usefixtures(*args)
    def scenario_wrapper(request, _pytest_bdd_example):
        scenario = templated_scenario.render(_pytest_bdd_example)
>       _execute_scenario(feature, scenario, request)

C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:174: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:144: in _execute_scenario
    _execute_step_function(request, scenario, step, step_func)
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:114: in _execute_step_function
    return_value = step_func(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

start_fruits = {'oranges': {'eat': 11.0, 'start': 12}}, start = 12, eat = 11.0
left = '3', fruits = 'oranges'

    @then(parsers.parse("I should have {left} {fruits}"))
    def should_have_left_fruits(start_fruits, start, eat, left, fruits):
        dump_obj(left, fruits)
    
        assert isinstance(left, str)
>       assert start - eat == int(left)
E       AssertionError: assert (12 - 11.0) == 3
E        +  where 3 = int('3')

test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py:32: AssertionError
_________________________ test_outline[5-4-7-apples] __________________________

request = <FixtureRequest for <Function test_outline[5-4-7-apples]>>
_pytest_bdd_example = {'eat': '4', 'fruits': 'apples', 'left': '7', 'start': '5'}

    @pytest.mark.usefixtures(*args)
    def scenario_wrapper(request, _pytest_bdd_example):
        scenario = templated_scenario.render(_pytest_bdd_example)
>       _execute_scenario(feature, scenario, request)

C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:174: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:144: in _execute_scenario
    _execute_step_function(request, scenario, step, step_func)
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:114: in _execute_step_function
    return_value = step_func(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

start_fruits = {'apples': {'eat': 4.0, 'start': 5}}, start = 5, eat = 4.0
left = '7', fruits = 'apples'

    @then(parsers.parse("I should have {left} {fruits}"))
    def should_have_left_fruits(start_fruits, start, eat, left, fruits):
        dump_obj(left, fruits)
    
        assert isinstance(left, str)
>       assert start - eat == int(left)
E       AssertionError: assert (5 - 4.0) == 7
E        +  where 7 = int('7')

test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py:32: AssertionError
_________________________ test_outline[5-4-3-oranges] _________________________

request = <FixtureRequest for <Function test_outline[5-4-3-oranges]>>
_pytest_bdd_example = {'eat': '4', 'fruits': 'oranges', 'left': '3', 'start': '5'}

    @pytest.mark.usefixtures(*args)
    def scenario_wrapper(request, _pytest_bdd_example):
        scenario = templated_scenario.render(_pytest_bdd_example)
>       _execute_scenario(feature, scenario, request)

C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:174: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:144: in _execute_scenario
    _execute_step_function(request, scenario, step, step_func)
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:114: in _execute_step_function
    return_value = step_func(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

start_fruits = {'oranges': {'eat': 4.0, 'start': 5}}, start = 5, eat = 4.0
left = '3', fruits = 'oranges'

    @then(parsers.parse("I should have {left} {fruits}"))
    def should_have_left_fruits(start_fruits, start, eat, left, fruits):
        dump_obj(left, fruits)
    
        assert isinstance(left, str)
>       assert start - eat == int(left)
E       AssertionError: assert (5 - 4.0) == 3
E        +  where 3 = int('3')

test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py:32: AssertionError
=========================== short test summary info ===========================
FAILED test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py::test_outline[12-11-7-apples]
FAILED test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py::test_outline[12-11-3-oranges]
FAILED test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py::test_outline[5-4-7-apples]
FAILED test_outlined_scenario_and_feature_with_parameter_join_by_one_parameter.py::test_outline[5-4-3-oranges]
============================== 4 failed in 0.15s ==============================

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions