Skip to content

Mix scenario outline and parser #404

@haomingyin

Description

@haomingyin

I'm trying to mix scenarios and parser to prevent repeating step definitions.

For example,

  Scenario Outline: Create users
    Given I want to create a user
    And my 'given_name' is <given_name>
    And my 'family_name' is <family_name>
    And my 'username' is <username>
    When I create the user
    Then the user will be created

    Examples:
      | given_name | family_name | username |
      | Tom        | Bob         | tom.bob  |

and the step definition is

@given("my '{attr_name}' is '<attr_value>'")
def build_request(attr_name, attr_value):
    # I would expect when attr_name is given_name and attr_value will be Tom
    # when attr_name is family_name and attr_value is Bob ...
    pass

obviously, it does not work. But I'm wondering if pytest-bdd supports use cases like that. As the user has 10+ attributes, it would be great to not repeat the step definitions.

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