失败重跑需要依赖pytest-rerunfailures插件,使用pip安装就行
pip install pytest-rerunfailures
安装pytest
pip install -U pytest
安装pytest-html的测试报告
pip install pytest-html
pytest-allure报告安装
pip install pytest-allure-adaptor
启动-带测试报告
pytest test_log.py --html=report.html
启动-带测试报告(保存css样式)
pytest test_log.py --html=report.html --self-contained-html
失败重跑 加reruns参数
pytest test_log.py --reruns 2 --html=report.html --self-contained-html
启动-带测试报告(保存到指定路径)
pytest test_log.py --reruns 2 --html=d:/test/report.html --self-contained-html
生成xml报告(allure)
pytest -s -q --alluredir report
如果不指定路径,默认在当前目录下新建一个report目录,也可以指定路径
pytest -s -q --alluredir 指定report路径
pytest test_log.py --html=d:/test/report.html --self-contained-html

本文详细介绍如何使用pytest进行自动化测试配置,包括安装pytest及其相关插件,如pytest-rerunfailures用于失败重跑,pytest-html和pytest-allure-adaptor生成测试报告。文中还提供了启动测试并生成不同格式报告的具体命令。
1114

被折叠的 条评论
为什么被折叠?



