默认pytest 运行完成之后,执行的结果 打印输出在控制台。

自动化测试运行完成之后,最好是有个html格式报告可以保存起来。

pytest中有比较多的第三方报告插件。

pytest-html

安装插件
image.png

运行

pytest-html 使用这个报告插件,不需要更改任何代码,只需要在运行的时候,添加对应的参数即可。

  1. pytest test_data.py test_demo.py --html=report.html --self-contained-html

运行的时候添加 --html=report.html --self-contained-html
可以生成测试报告。
image.png