安装插件
pip install pytest-rerunfailures
参考文档: https://pypi.org/project/pytest-rerunfailures/
使用方法
重跑所有失败的用例
使用–reruns num,num是要重跑的次数
pytest --reruns 5
比如如下在test_simpleexample.py中的测试用例:
import pytest
import logging
LOG=logging.getLogger(__name__)
def inc(x):
return x+1
a=0
@pytest.mark.skipif(a>1,reason="a>1")
def test_inc():
assert inc(5)==6
def test_inc2