pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告。兼容Python 2.7,3.6

pytest-html

1、github上源码地址【https://github.com/pytest-dev/pytest-html】

2、pip安装

pip install pytest-html

3、执行方法

pytest --html=report.html  

html报告

1、打开cmd,cd到需要执行pytest用例的目录,执行指令:pytest --html=report.html  

2、执行完之后,在当前目录会生成一个report.html的报告文件,显示效果如下

pytest-pytest-html生成HTML测试报告

 指定报告路径

直接执行"pytest --html=report.html"生成的报告会在当前脚本的同一路径,如果想指定报告的存放位置,放到当前脚本的同一目录下的report文件夹里

pytest --html=./report/report.html  

报告独立显示

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

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

更多可以查阅官方文档【https://github.com/pytest-dev/pytest-html】

相关文章:

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