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

 pytest-html

1.  pip 安装: pip install pytest-html

2.  执行方法: pytest (-q 指定py脚本文件) --html = report.html【目标html名称,直接写名称是在当前目录下,也可定义目录下的文件夹:./ xx文件夹/ xx.html】

随便找一个脚本执行实例看下:

pytest自动化5:pytest-html插件--生成html报告

好了,在demo1文件夹下可以找到report.html,打开就可以看到报告了:

pytest自动化5:pytest-html插件--生成html报告

3.  失败重试

 失败重跑需要依赖pytest -rerunfailures插件,使用pip安装即可。

 pip安装命令:pip install pytest-rerunfailures

 执行命令:pytest xx.py --reruns 1 --html=report2.html --self-contained-html    【--self-contained-html加这个是为了生成的html文件自带css样式】

pytest自动化5:pytest-html插件--生成html报告

从报告可以看出,rerun 一次。

 

相关文章:

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