Tags(smoke/regression) to be passed from CLI and to be interpreted in conftest.py to execute those scenarios satisfying the tags.
I've looked into the pytest-bdd document here and failed to find the connection.
Scenario Outline has: (as python decorators can be stacked)
@pytest.mark.smoke
Scenario Outline: "VALID" Test
@pytest.mark.smoke
@pytest.mark.regression
Scenario Outline: "INVALID" Test
@pytest.mark.regression
Scenario Outline: "MIXED" Test
conftest.py
def pytest_bdd_apply_tag(tag, function):
if 'smoke' not in tag: #what should I use to take values from CLI and execute those
marker = pytest.mark.skip # skips scenario where 'smoke' is not marked
marker(function)
return True
return None
The above code in conftest.py skips all scenarios. CLI Input:
pytest --env='qa' -m 'smoke'
where pytest_addoption is used for --env='qa' and pytest_bdd_apply_tag for -m.
We want to execute only scenarios that have marked smoke(VALID & INVALID) when I pass smoke; scenarios that have marked regression(INVALID & MIXED) when I pass regression and default smoke when I don't pass any parameter in CLI via -m option.