标记(烟雾/回归)将从CLI传递,并在conftest.py中进行解释,以执行满足这些标记的方案。
我查看了pytest-bdd文档这里,但未能找到连接。
场景大纲有:(因为python装饰器可以堆叠)
@pytest.mark.smoke
Scenario Outline: "VALID" Test
@pytest.mark.smoke
@pytest.mark.regression
Scenario Outline: "INVALID" Test
@pytest.mark.regression
Scenario Outline: "MIXED" Testconftest.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 Noneconftest.py中的上述代码跳过所有场景。CLI输入:
pytest --env='qa' -m 'smoke'
其中pytest_addoption用于--env='qa',pytest_bdd_apply_tag用于-m。
我们只希望在传递烟雾时执行标记为烟雾(有效和无效)的方案;在传递回归时执行标记为回归(无效和混合)的方案;在不通过-m选项传递任何参数的情况下执行默认烟雾。
发布于 2019-06-10 17:39:46
糟糕的是,我想知道我是如何被pytest标记与场景标记行误导的,就像文档中提到的那样。
我对特性文件所做的更改是
@smoke
Scenario Outline: "VALID" Test
@smoke @regression
Scenario Outline: "INVALID" Test
@regression
Scenario Outline: "MIXED" Test我已经从pytest_bdd_apply_tag中删除了conftest.py方法。
在命令行中给这个对我有用。
pytest -m "regression" --env="uat"https://stackoverflow.com/questions/56484952
复制相似问题