Skip to content

Tags support for Example sections #411

Closed
@elchupanebrej

Description

@elchupanebrej

When I have Feature file like:

Feature: Foo
  Background:
    Given Step <bar>

    @cool_background_tag
    Examples:
    |bar|
    | 10|

    @nice_background_tag
    Examples:
    |bar|
    | 45|

  Scenario Outline: Fizz
    Given Step <buzz>

    @bad_scenario_tag
    Examples:
    |buzz|
    | 10|

    @ugly_scenario_tag
    Examples:
    |buzz|
    | 45|

and invoke pytest like:

# Runs Background only Examples for this tag:
pytest -m cool_background_tag
# Runs Scenario Outline only Examples for this tag:
pytest -m ugly_scenario_tag
# Other cases which also possible:
pytest -m "cool_background_tag and not bad_scenario_tag"
pytest -m "cool_background_tag or nice_background_tag"

pytest-bdd respects added tags

NB:

Gherkin parser already has such model and it already used here: https://behave.readthedocs.io/en/latest/new_and_noteworthy_v1.2.6.html#index-0

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