首页 > Web开发 > 详细

3. HttpRunner运行测试用例

时间:2020-10-29 19:47:32      阅读:100      评论:0      收藏:0      [点我收藏+]

以多种方式运行测试用例

执?单个测试?例

> hrun filepath/testcase.yml

执?多个测试?例

> hrun testcase1.yml testcase2.yml

执?整个文件夹下的用例

> hrun folder_path

运行测试脚本

基于之前生成的json、yaml文件,通过命令行终端cd到用例所在目录,执行hrun + 用例名称即可运行测试脚本。

> hrun index.yml
INFO     HttpRunner version: 2.5.7
INFO     Start to run testcase: testcase description
/index
INFO     GET http://localhost.charlesproxy.com:8000/index
INFO     status_code: 200, response_time(ms): 42.89 ms, response_length: 32 bytes

.

----------------------------------------------------------------------
Ran 1 test in 0.048s

OK
INFO     Start to render Html report ...
INFO     Generated Html report: D:\api-auto-test\hrun_demo\reports\2020-10-29_17_55_03.html
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-Break to quit

在console中可以看到请求的概要信息, 包括请求的地址、状态码、运行的用例数量、生成的测试报告路径...信息, 如需要在控制台查看请求具体信息, 可在运行时加上--log-level debug参数。


查看测试报告

执行完测试用例会在当前目录创建一个reports文件夹,里面会有一个按时间戳生成的html格式报告文件,我们打开看一哈
技术分享图片

点开测试步骤detail列的log-1可以查看请求的具体信息

请求数据(Request)
技术分享图片

响应数据(Response)
技术分享图片

断言校验字段(Validate):
技术分享图片

3. HttpRunner运行测试用例

原文:https://www.cnblogs.com/kyle-/p/13898116.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!