- 生成报告借助pytest-html 库,安装pip install pytest-html
- 执行测试时,使用 pytest --html=xxx.html,在当前目录下生成xxx.html
- pytest --html=./report/report.html生成的报告将存放在当前目录report路径下
失败重试
- 失败重跑需要依赖pytest-rerunfailures插件
- 用例失败再重跑添加reruns参数即可 py.test --reruns 1 --html=report.html
-
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.#隔多久重跑
py.test --reruns 1 --html=report.html --reruns-delay 5