【实践】_HttpRunner_快速上手

1.环境安装
pip install httprunner
2.验证安装结果
hrun -V
har2case -V

安装成功

3.通过脚手架工具生成工程目录结构
hrun --startproject api_autotest

【实践】_HttpRunner_快速上手_第1张图片
创建工程

4.快速上手
(1).testcases目录下新建test_demo.yml文件,内容如下:

# 全局配置
- config:
# 本用例集名称
name: testsuites name
base_url: http://oms.reedhuabo.com
# 具体的测试用例
- test:
# 用例名称
name: /api/main/index
request:
    headers:
        Accept: application/json
    json:
    method: GET
url: /api/main/index
validate:
- eq: [status_code, 200]
- eq: [content.errorCode, 0]

(2).保存后,cmd到工程目录下执行 hrun testcases\test_demo.yml,结果如下说明执行成功:

执行成功

(3).查看报告,在工程目录下的reports目录

你可能感兴趣的:(【实践】_HttpRunner_快速上手)