Pytest重运行机制


第一种:对所有用例使用
1、安装:pip install pytest-rerunfailures 2、命令行参数:pytest -- reruns 重试次数 (--reruns-delay 次数之间间隔)                   pytest --reruns 2 运行失败的用例可以执行2次                   pytest --reruns 2 --reruns-delay 5 运行失败的用例可以执行2次,每次间隔5秒 pytest.main(["-v","-m","demo","--reruns","2","--reruns-delay","5","--alluredir=../OutPuts/allure-results"]) pytest中的失败截图。 第二种:只对部分用例使用重运行机制
在指定的用例使用装饰器 @pytest.mark.flaky(reruns
=5, reruns_delay=2) def test_example():     import random     assert random.choice([True, False])


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM