其他分享
首页 > 其他分享> > 002_pytest_失败用例的重跑机制_@pytest.mark.flaky()

002_pytest_失败用例的重跑机制_@pytest.mark.flaky()

作者:互联网

# 执行失败了的用例可以按照一定频率去跑多次,频率+次数。
# reruns=2          重跑次数
# reruns_delay=2    频率


import pytest
import os
import allure

@pytest.mark.flaky(reruns=2,reruns_delay=2) #只有失败的用例才重跑
@pytest.mark.parametrize('a', [100, 200, 300])
def test_001(a):
    assert a == 200

if __name__ == '__main__':
    pytest.main(['002_pytest_失败用例的重跑机制.py', '-s', '--alluredir', '../report/tmp'])
    # os.system('allure generate ../report/tmp -o ../report/report --clean')
    os.system('allure serve ../report/tmp -o ../report/report --clean')

标签:__,reruns,..,mark,用例,pytest,重跑,report
来源: https://blog.csdn.net/weixin_44801980/article/details/117886703