pytest失败重跑

失败重跑需要依赖pytest-rerunfailures插件,使用pip安装就行

pip install pytest-rerunfailures

用例失败重跑的方法:

  1. 在用例上添加装饰器@pytest.mark.flaky(reruns=2, reruns_delay=4)  reruns为次数,reruns_delay间隔时间,单位s(对部分用例生效)

  2. 在pytest.ini文件中addopts = 添加参数–reruns n (n:为重试的次数)(对所有用例生效)

方法一:单个用例失败重跑

方法二:所有用例失败重跑

原文地址:https://www.cnblogs.com/crystal1126/p/12580953.html