httprunner 3.x学习6 - 生成 html 测试报告

前言

HttpRunner 3.x版可以使用所有的 pytest 插件,包括测试报告插件,像的 pytest-html 和 allure-pytest 。

pytest-html

httprunner 安装的时候,会自动安装 pytest 和 pytest-html 插件,对应的版本号是

  • pytest 5.4.3
  • pytest-html 2.1.1
C:\Users\dell>pip show pytest
Name: pytest
Version: 5.4.3

C:\Users\dell>pip show pytest-html
Name: pytest-html
Version: 2.1.1

hrun 生成报告

hrun 命令生成报告的时候,带上 --html 指定报告路径

>hrun testcases/login_userinfo_test.py --html=./reports/result.html

--html 参数生成的报告,css文件是单独分开的,不方便查看,可以加上--self-contained-html参数让css文件集成到html上

>hrun testcases/login_userinfo_test.py --html=./reports/result.html --self-contained-html

运行结果

查看html报告

pytest 生成报告

用 hrun 运行生成的报告会出现一大堆的报错: OSError: [WinError 6] 句柄无效。并且无法显示 request 和 response 内容。
hrun 执行pytest用例还不太完善,尽量用pytest去执行py脚本

>pytest testcases/login_userinfo_test.py --html=./reports/result.html --self-contained-html

执行后查看报告

allure 报告

httprunner3 也可以支持 allure 插件,需 pip 安装

> pip install allure-pytest

相关教程看这篇https://www.cnblogs.com/yoyoketang/p/12004145.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值