如果是
@todo
标签,我需要向 Zephyr Scale 发送跳过测试的请求。
def pytest_bdd_apply_tag(tag, function):
env = os.environ.get(ENV_VARIABLE)
if tag == 'todo':
marker = pytest.mark.skip(reason="Not implemented yet")
marker(function)
## Get issue number
# match = re.search(r'\[([A-Z]+-[^\]]+)\]', scenario.name)
## Send request to Zephyr Scale
# ZephyrScale(match.group(1)).set_skipped()
return True
else:
# Fall back to the default behavior of pytest-bdd
return None
是否有任何选项可以获取场景名称?
通过扩展
todo
-tag 解决
https://pytest-bdd.readthedocs.io/en/latest/
标签名称中允许有空格。当使用 pytest_bdd_apply_tag 钩子和 @xfail 之类的标签时,这可能很有用:某些原因。
@todo: /{TEST CYCLE}/ [TEST-CASE] CSRF Token invalid
Scenario: [TEST-CASE] Roundtrip return drive error
When ...
def pytest_bdd_apply_tag(tag, function):
env = os.environ.get(ENV_VARIABLE)
if tag.startswith("todo"):
marker = pytest.mark.skip(reason="Not implemented yet")
marker(function)
match = re.search(r'/(.*?)/ \[([A-Z]+-[^\]]+)\] (.*?)', tag)
if match:
ZephyrScale(match.group(1)).set_skipped(match.group(2), match.group(3))
return True
else:
# Fall back to the default behavior of pytest-bdd
return None