Gherkin tag as pytest tag¶
Gherkin support tags on multiple keywords, such as Feature
, Rule
, Scenario
and Scenario Outline
.
All of them can be used to set a pytest mark and use the -m
option of pytest.
Skipping tests¶
Feature: Discover Gherkin tag
@skip
Scenario: I can skip a test
Given a user Bob
This test will be skipped because of the @skip
tag:
uv run pytest -v
========================== test session starts ==========================
platform linux -- Python 3.13.2, pytest-8.3.5, pluggy-1.5.0
configfile: pyproject.toml
plugins: cov-6.0.0
collected 1 item
tests/functionals/test_1_Discover_Gherkin_tag.py::test_2_I_can_skip_a_test SKIPPED (unconditional skip) [100%]
========================== 1 skipped in 0.01s ===========================
Writing a wip tag¶
Feature: Discover Gherkin tag
@wip
Scenario: I work on this test
Given a user Alice
Scenario: This test is not runned
Given a user Bob
Now to avoid warning, markers have to be registered in pytest options, in pyproject.toml:
[tool.pytest.ini_options]
markers = ["wip: work in progress."]
𝝿 uv run pytest tests/functionals2 -m wip
========================== test session starts ==========================
platform linux -- Python 3.13.2, pytest-8.3.5, pluggy-1.5.0
configfile: pyproject.toml
plugins: cov-6.0.0
collected 2 items / 1 deselected / 1 selected
tests/functionals/test_1_Discover_Gherkin_tag.py [100%]
=================== 1 passed, 1 deselected in 0.01s =====================