pytest-重运行机制--rerunfailures插件

介绍
  • 下载插件
pip install pytest-rerunfailures
  • pytest提供了失败重试机制:
      插件名称:rerunfailures
      安装方法pip install -U pytest-rerunfailures -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
  • 使用方式
    命令行参数形式:
      命令:pytest --reruns 重复次数
eg:pytest --reruns 2表示:运行失败的用例可以重新运行2次

  命令:pytest --reruns重复次数 --reruns-delay 次数之间的延时设置(单位:秒)

pytest -reruns 2 --reruns-delay 5 
表示失败的用例可以重新运行2次,第一次和第二次间隔时间为5秒

# 重运行
pytest.main(['testcase/test_demo3.py',
              '--reruns', '3',
              '--reruns-delay', '5',
              '--alluredir=allure_reports'])

# pytest --reruns 3 --reruns-delay 5
image.png
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。