环境前提

Python3.6+

安装插件

pip3 install pytest-html -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

快速入门

pytest --html=report.html

会在当前目录下创建一个report.html的测试报告
Pytest学习(十二)-生成HTML报告插件之pytest-html的使用

为什么你的报告没有样式

上面命令生成的报告,css是独立的,分享报告的时候样式会丢失,为了更好的分享发邮件展示报告,可以把css样式合并到html里

pytest --html=report.html --self-contained-html

测试报告:
Pytest学习(十二)-生成HTML报告插件之pytest-html的使用

注意事项

  • 在将文件或链接添加到独立报告时,插件会发出warnings;
  • 在html测试报告中可能无法按预期显示文件或链接

系列参考文章:
https://www.cnblogs.com/poloyy/category/1690628.html

相关文章:

  • 2021-07-02
  • 2022-01-26
  • 2022-02-24
  • 2021-07-13
  • 2021-06-19
猜你喜欢
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2021-08-02
  • 2021-12-15
相关资源
相似解决方案