httprunner学习10-测试报告ExtentReport
前言
httprunner默认生成的报告不怎么美观,里面还有第二套报告模板extent_report_template.html。
extent_report_template
使用 hrun -h 可以看到运行的时候可以添加的命令行参数
C:\Users\dell>hrun -h
usage: hrun [-h] [-V] [--no-html-report] [--html-report-name HTML_REPORT_NAME]
[--html-report-template HTML_REPORT_TEMPLATE]
[--log-level LOG_LEVEL] [--log-file LOG_FILE]
[--dot-env-path DOT_ENV_PATH] [--failfast]
[--startproject STARTPROJECT]
[--validate [VALIDATE [VALIDATE ...]]]
[--prettify [PRETTIFY [PRETTIFY ...]]]
[testset_paths [testset_paths ...]]
One-stop solution for HTTP(S) testing.
positional arguments:
testset_paths testset file path
optional arguments:
-h, --help show this help message and exit
-V, --version show version
--no-html-report do not generate html report.
--html-report-name HTML_REPORT_NAME
specify html report name, only effective when
generating html report.
--html-report-template HTML_REPORT_TEMPLATE
specify html report template path.
--log-level LOG_LEVEL
Specify logging level, default is INFO.
--log-file LOG_FILE Write logs to specified file path.
--dot-env-path DOT_ENV_PATH
Specify .env file path, which is useful for keeping
production credentials.
--failfast Stop the test run on the first error or failure.
--startproject STARTPROJECT
Specify new project name.
--validate [VALIDATE [VALIDATE ...]]
Validate JSON testset format.
--prettify [PRETTIFY [PRETTIFY ...]]
Prettify JSON testset format.
使用 --html-report-template参数可以替换自己的模板,后面指定模板的路径:E:\python36\Lib\site-packages\httprunner\templates\extent_report_template.html
hrun test_demo.yml --html-report-template /path/templates/extent_report_template.html
D:\soft\untitled>hrun test_demo.yml --html-report-template E:\python36\Lib\site-packages\httprunner\templates\extent_report_template.html
test_demo case1
INFO GET http://127.0.0.1:8000/api/test/demo
INFO status_code: 200, response_time(ms): 39.2 ms, response_length: 255 bytes
INFO start to extract from response object.
INFO start to validate.
.
----------------------------------------------------------------------
Ran 1 test in 0.049s
OK
INFO render with html report template: E:\python36\Lib\site-packages\httprunner\templates\extent_report_template.html
INFO Start to render Html report ...
INFO Generated Html report: D:\soft\untitled\reports\1569369482.html
D:\soft\untitled>
查看extentreport报告
查看extentreport测试报告,默认黑色主题

也可以切换成白色主题

默认使用extentreport报告
如果你不想每次输入这么长的参数,我们可以修改源码。默认使用extent_report_template.html
找到\site-packages\httprunner\report.py文件,相关代码
def render_html_report(summary, html_report_name=None, html_report_template=None):
""" render html report with specified report name and template
if html_report_name is not specified, use current datetime
if html_report_template is not specified, use default report template
"""
if not html_report_template:
html_report_template = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
"templates",
"default_report_template.html"
)
logger.log_debug("No html report template specified, use default.")
else:
logger.log_info("render with html report template: {}".format(html_report_template))
修改后代码
def render_html_report(summary, html_report_name=None, html_report_template=None):
""" render html report with specified report name and template
if html_report_name is not specified, use current datetime
if html_report_template is not specified, use default report template
"""
if not html_report_template:
html_report_template = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
"templates",
"extent_report_template.html"
)
logger.log_debug("No html report template specified, use extent_report_template.")
elif html_report_template == 'default':
html_report_template = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
"templates",
"default_report_template.html"
)
logger.log_debug("render with html report template: default_report_template.")
else:
logger.log_info("render with html report template: {}".format(html_report_template))
这样默认就会生成extentreport
hrun test_demo.yml
带上default参数就会生成原始的报告
hrun test_demo.yml --html-report-template default
httprunner学习10-测试报告ExtentReport的更多相关文章
- httprunner学习15-运行用例命令行参数详解
前言 HttpRunner 在命令行中启动测试时,通过指定参数,可实现丰富的测试特性控制. 命令行参数CLI 使用 -h 查看相关命令行参数 hrun -h 参数名称 参数值 参数说明 -h, --h ...
- JavaScript学习10 JS数据类型、强制类型转换和对象属性
JavaScript学习10 JS数据类型.强制类型转换和对象属性 JavaScript数据类型 JavaScript中有五种原始数据类型:Undefined.Null.Boolean.Number以 ...
- ThinkPhp学习10
原文:ThinkPhp学习10 查询操作 Action模块 User下的search public function search(){ //判断username是否已经传入,且不为空 if(isse ...
- HttpRunner学习8--使用debugtalk.py辅助函数
前言 在HttpRunner中,我们的测试用例都是写在 YAML/JSON 文件中,有时候我们想借助代码来实现某些较复杂的功能,但在 YAML/JSON 中是无法直接写代码来处理的,这个时候,我们可以 ...
- python学习10—迭代器、三元表达式与生成器
python学习10—迭代器.三元表达式与生成器 1. 迭代器协议 定义:对象必须提供一个next方法,执行该方法或者返回迭代中的下一项,或者返回一个StopIteration异常,以终止迭代(只能往 ...
- HttpRunner学习9--切换测试报告模板
前言 在HttpRunner中,给我们提供了 2 套测试报告模板,分别是 default_report_template.html 和 extent_report_template.html . 默认 ...
- HttpRunner学习6--使用parameters参数化
前言 在使用HttpRunner测试过程中,我们可能会遇到这种场景: 账号登录功能,需要输入用户名和密码,设计测试用例后有 N 种组合情况 如果测试组合比较少,比如只有2个,那我们直接在YAML脚本中 ...
- HttpRunner学习7--引用CSV文件数据
前言 在之前的文章中,我们已经学习了 parameters 参数化,是在测试脚本中直接指定参数列表.这种方法简单易用,但如果我们的参数列表数据比较多,这种方法可能就不太适合了. 当数据量比较大的时候, ...
- HttpRunner学习2--用例格式和简单使用
前言 HttpRunner中,测试用例支持两种文件格式:YAML 和 JSON.两种格式的用例是完全等价的,对于相同的信息内容,使用 YAML /JSON 得到的测试结果和报告也是一致的. 本人环境: ...
随机推荐
- Apache Beam实战指南 | 大数据管道(pipeline)设计及实践
Apache Beam实战指南 | 大数据管道(pipeline)设计及实践 mp.weixin.qq.com 策划 & 审校 | Natalie作者 | 张海涛编辑 | LindaAI 前 ...
- C# 激活主窗口
今天同学跟我说了一个bug,虽然很简单,但还是记录一下,也好让我养成写东西的习惯. C# windows form 程序中,发生某个事件时,需要自动弹出一个窗口,提示用户,并等待用户输入进行处理. 如 ...
- 腾讯云IPv6技术拿了个一等奖!1.5亿人已经用上
中国通信学会在其官网上公布了2019年中国通信学会科学技术奖的评选结果,腾讯云和中国移动通信集团,中国信息通信研究院.以及华为联合申报的“移动互联网IPv6技术攻关及规模应用”项目荣获今年科学技术一等 ...
- [转帖]OLAP引擎这么多,为什么苏宁选择用Druid?
OLAP引擎这么多,为什么苏宁选择用Druid? 原创 51CTO 2018-12-21 11:24:12 [51CTO.com原创稿件]随着公司业务增长迅速,数据量越来越大,数据的种类也越来越丰富, ...
- Matlab分布云图绘制(渐变彩色)
方法1. 函数:fill 举例说明:应力分布云图 x=[0 1 1 0 0]; %x坐标 y=[0 0 1 1 0]; %y坐标 stress=[1 2 3 4 1] %应力大小 fill(x,y,s ...
- bootstrap table--面相配置、hook、适配的表格框架
bootstrap table--面相配置.hook.适配的表格框架
- 用友U9 UFSoft.UBF.Business.Session
Session的概念 在现在UBF中,Session的本意是work unit,即持久层的一个边界,非常轻,主要用作批量提交,并标识这次批量提交的边界,不涉及到事务等概念. 当前ISession可以通 ...
- vue/react/angular开发的css架构思考
前端开发现在已经从传统的后端web多页面开发模式转向前端单页SPA开发模式,而vuejs/react/angular则是开发SPA非常优秀的前端框架.组件化开发由react最早提出,vuejs后发优势 ...
- Java自学-面向对象 属性
Java类的属性 一个英雄有姓名,血量,护甲等等状态 这些状态就叫做一个类的属性 步骤 1 : 属性的类型 属性的类型可以是基本类型,比如int整数,float 浮点数 也可以是类类型,比如Strin ...
- Django---Http协议简述和原理,HTTP请求码,HTTP请求格式和响应格式(重点),Django的安装与使用,Django项目的创建和运行(cmd和pycharm两种模式),Django的基础文件配置,Web框架的本质,服务器程序和应用程序(wsgiref服务端模块,jinja2模板渲染模块)的使用
Django---Http协议简述和原理,HTTP请求码,HTTP请求格式和响应格式(重点),Django的安装与使用,Django项目的创建和运行(cmd和pycharm两种模式),Django的基 ...