Skip to content

Validation of duplicated parameters for usual and vertical examples is made not in the same way #482

@elchupanebrej

Description

@elchupanebrej

When I execute Feature:

Feature: Outline
    Scenario Outline: Outlined with wrong vertical example table
        Given there are <start> cucumbers
        When I eat <eat> cucumbers
        Then I should have <left> cucumbers

        Examples:
        | start | start | left |
        |   12  |   10  |   7  |
        |    2  |    1  |   1  |

I got output:

=================================== ERRORS ====================================
___ ERROR collecting test_wrongly_outlined_duplicated_parameter_scenario.py ___
test_wrongly_outlined_duplicated_parameter_scenario.py:3: in <module>
    @scenario("outline.feature", "Outlined with wrong vertical example table")
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:244: in scenario
    scenario.validate()
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\parser.py:269: in validate
    raise exceptions.ScenarioExamplesNotValidError(
E   pytest_bdd.exceptions.ScenarioExamplesNotValidError: Scenario "Outlined with wrong vertical example table" in the feature "C:\Users\bulky\AppData\Local\Temp\pytest-of-bulky\pytest-96\test_wrongly_outlined_duplicated_parameter_scenario0\outline.feature" has not valid examples. Set of step parameters ['eat', 'left', 'start'] should match set of example values ['left', 'start'].
=========================== short test summary info ===========================
ERROR test_wrongly_outlined_duplicated_parameter_scenario.py - pytest_bdd.exc...
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
============================== 1 error in 0.16s ===============================

And when I execute feature

Feature: Outline
    Scenario Outline: Outlined with wrong vertical example table
        Given there are <start> cucumbers
        When I eat <eat> cucumbers
        Then I should have <left> cucumbers

        Examples: Vertical
        | start | 12 | 2 |
        | start | 10 | 1 |
        | left  | 7  | 1 |

I got output:

=================================== ERRORS ====================================
_ ERROR collecting test_wrongly_outlined_duplicated_parameter_vertical_scenario.py _
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\parser.py:172: in parse_feature
    (scenario or feature).examples.add_example_row(param_line_parts[0], param_line_parts[1:])
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\parser.py:420: in add_example_row
    raise exceptions.ExamplesNotValidError(
E   pytest_bdd.exceptions.ExamplesNotValidError: Example rows should contain unique parameters. "start" appeared more than once

During handling of the above exception, another exception occurred:
test_wrongly_outlined_duplicated_parameter_vertical_scenario.py:3: in <module>
    @scenario("outline.feature", "Outlined with wrong vertical example table")
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\scenario.py:232: in scenario
    feature = get_feature(features_base_dir, feature_name, encoding=encoding)
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\feature.py:54: in get_feature
    feature = parse_feature(base_path, filename, encoding=encoding)
C:\Users\bulky\Projects\pytest-bdd\pytest_bdd\parser.py:175: in parse_feature
    raise exceptions.FeatureError(
E   pytest_bdd.exceptions.FeatureError: Scenario has not valid examples. Example rows should contain unique parameters. "start" appeared more than once.
E   Line number: 9.
E   Line: | start | 10 | 1 |.
E   File: outline.feature
=========================== short test summary info ===========================
ERROR test_wrongly_outlined_duplicated_parameter_vertical_scenario.py - pytes...
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
============================== 1 error in 0.17s ===============================

So the first example raises ScenarioExamplesNotValidError and the second one raises FeatureError because of the same reason

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