Feature: Scenarios could be tagged ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Background: ''''''''''' - Given File "steps.feature" with content: .. code:: gherkin Feature: Steps are executed by corresponding step keyword decorator @passed Scenario: Passed Given I produce passed test @failed Scenario: Failed Given I produce failed test @both Rule: Scenario: Passed Given I produce passed test Scenario: Failed Given I produce failed test - Given File "pytest.ini" with content: .. code:: ini [pytest] markers = passed failed both - And File "conftest.py" with content: .. code:: python from pytest_bdd.compatibility.pytest import fail from pytest_bdd import given @given('I produce passed test') def passing_step(): ... @given('I produce failed test') def failing_step(): fail('Enforce fail') Scenario: Run pytest selecting tests tagged with ``passed`` ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - When run pytest ======== == ====== cli_args -m passed ======== == ====== ======== == ====== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 0 ====== ====== Scenario: Run pytest selecting tests tagged with ``failed`` ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - When run pytest ======== == ====== cli_args -m failed ======== == ====== ======== == ====== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 0 1 ====== ====== Scenario: Run pytest selecting tests tagged with ``passed`` or ``failed`` ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - When run pytest ======== == ================ cli_args -m passed or failed ======== == ================ ======== == ================ - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 1 ====== ====== Scenario: Run pytest selecting tests not tagged with ``both`` ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - When run pytest ======== == ======== cli_args -m not both ======== == ======== ======== == ======== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 1 ====== ====== Scenario: Run pytest selecting tests tagged with ``both`` ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - When run pytest ======== == ==== cli_args -m both ======== == ==== ======== == ==== - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 1 1 ====== ====== Scenario: Run pytest without marker selection (all tests) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - When run pytest - Then pytest outcome must contain tests with statuses: ====== ====== passed failed ====== ====== 2 2 ====== ======