前言
有些接口可能不太稳定,第一次跑的时候由于网络原因或者其它原因失败,但是重新跑2次又成功了。
对于这种需要重新跑几次的场景,可以使用用例失败重跑机制,需安装pytest-rerunfailures 插件。
场景示例
失败重跑需要依赖 pytest-rerunfailures 插件,使用 pip 安装就行
pip install pytest-rerunfailures
关于reruns参数的2个用法
re-run failing tests to eliminate flaky failures:
--reruns=RERUNS number of times to re-run failed tests. defaults to 0.
--reruns-delay=RERUNS_DELAY
add time (seconds) delay between reruns.
以下示例,故意让第二个用例失败test_demo.yml
test_get_demo:
name