Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags support for Example sections #411

Closed
elchupanebrej opened this issue Mar 30, 2021 · 6 comments · Fixed by #738
Closed

Tags support for Example sections #411

elchupanebrej opened this issue Mar 30, 2021 · 6 comments · Fixed by #738

Comments

@elchupanebrej
Copy link

elchupanebrej commented Mar 30, 2021

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

@moattarwork
Copy link

Any update on this feature?

@willribemoreno
Copy link

news?

@elchupanebrej
Copy link
Author

elchupanebrej commented Aug 15, 2021

@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

@VladimirChernev
Copy link

bump

@elchupanebrej
Copy link
Author

@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

@AlirezaRoshanzamir
Copy link

AlirezaRoshanzamir commented Nov 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants