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

网易云课程地址



点我 ->立即报名

posted @   上海-悠悠  阅读(1167)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2019-06-16 第9期《python3接口自动化测试》课程,6月29号开学!
点击右上角即可分享
微信分享提示