3. HttpRunner运行测试用例

以多种方式运行测试用例

执⾏单个测试⽤例

> 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格式报告文件,我们打开看一哈
test_report

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

请求数据(Request)
请求信息

响应数据(Response)
响应数据

断言校验字段(Validate):
校验信息

posted @ 2020-10-29 18:12  老板,卖油条不?  阅读(202)  评论(0编辑  收藏  举报
/* 鼠标点击依次出现不同选项效果 */ /* 鼠标点击烟花效果 */
/* 背景线条 */