pytest 框架之pytest-html报告生成

一、关于安装

pytest-html属于pytest的一个插件,使用它需要先安装

pip install pytest-html

pytest可以生成多种样式的结果:

生成 JunitXML 格式的测试报告,命令 : --junitxml= path
生成 ResultLog 格式的测试报告,命令: --resultlog=report/log.txt
生成 Html 格式的测试报告,命令: --html=OutPuts/reports/report.html (相对路径)

二、生成html报告

import pytest

if __name__ == '__main__':
  # 生成pytest-html报告 pytest.main([
'-s', '-v', '--html=Outputs/reports/report.html'])

生成的测试报告位置:

打开测试报告:

*******尊重作者,本文是本人转载自:https://www.cnblogs.com/xiaogongjin/    ******* 

猜你喜欢

转载自www.cnblogs.com/shouhu/p/12276140.html