pytest-bdd icon indicating copy to clipboard operation
pytest-bdd copied to clipboard

Tags support for Example sections

Open elchupanebrej opened this issue 4 years ago • 6 comments
trafficstars

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

elchupanebrej avatar Mar 30 '21 14:03 elchupanebrej

Any update on this feature?

moattarwork avatar Jul 22 '21 10:07 moattarwork

news?

willribemoreno avatar Jul 27 '21 14:07 willribemoreno

@olegpidsadnyi could you please check #413 and provide some timeline for parser rewriting.

There could be one good step to untangle development: split parsing and execution models maybe with some marshalling in between as it was done in Cucmber.io project.

This feature uses aspects of Gherkin dialect which were not presented by Gherkin originally (pytest-bdd and Cucumber.io Gherkin dialects are different). I have a branch that could execute a model provided by Cucumber.io community. Before I could create new PR I want to know that this feature could have a future in this project.

@olegpidsadnyi please review this feature and put it if possible to a roadmap

elchupanebrej avatar Aug 15 '21 12:08 elchupanebrej

bump

VladimirChernev avatar Nov 25 '22 15:11 VladimirChernev

@VladimirChernev could I ask you to check https://github.com/elchupanebrej/pytest-bdd-ng fork? It doesn't support examples in background sections (because Gherkin specification doesn't support them), but it supports tags for example sections

elchupanebrej avatar Nov 29 '22 22:11 elchupanebrej

I implemented this feature using pytest-bdd internals and also using the pytest_collection_modifyitems function: https://stackoverflow.com/a/76653953/6628488

AlirezaRoshanzamir avatar Nov 26 '23 12:11 AlirezaRoshanzamir