C05_HttpRunner测试框架文件编写规范:api 接口文件规范

本文详细介绍了HttpRunner测试框架中API文件的编写规范,包括如何使用JSON/YAML格式存储接口描述,以及推荐的关键字如name、base_url等,旨在帮助测试人员更有效地管理和测试接口。
摘要由CSDN通过智能技术生成

C05_HttpRunner测试框架文件编写规范:api 接口文件规范

 

在接口测试中,除了对单个接口进行测试,还经常涉及多个接口进行联合测试,接口会被复用。为了更好地对接口描述进行管理,HttpRunner 可以使用独立的 JSON/YAML 文件对接口描述进行存储,即每个文件对应一个接口描述。另外,官方建议 API 描述需要尽量保持完整,做到可以单独运行。

 

 

每个 api 文件和测试用例(testcase)文件的内容基本是相同的。相当于把用例中针对某个 url 接口的测试步骤提取出来,单独存储为一个 JSON/YAML 文件。

 

 

 

接口文件规范的定义:httprunner-2.5.5\httprunner\loader\schemas\api.schema.json

允许使用的关键字包括:name、base_url、variables、request、setup_hooks、teardown_hooks、extract、validate ,具体每项的含义可以参考测试用例(testcase)章节的介绍。

 

 

 

 

 

独立的接口(api)文件格式(YAML格式)举例:

 

 

 

用sql解析一下以下josn: [{"supply_id":"c05debb4-55d5-4c46-85e9-b0ae4b40658d","is_enabled":true,"supply_code":3251,"supply_name":"乐颐食品(深圳)有限公司","before_cost_unit":390,"after_cost_unit":360,"diff_cost_unit":-30,"diff_cost_unit_percentage":-7.69,"before_gross_margin_percentage":21.69,"after_gross_margin_percentage":27.71,"diff_gross_margin_percentage":6.02},{"supply_id":"c7cb2c72-d608-46dc-9650-b31d922fc515","is_enabled":false,"supply_code":3690,"supply_name":"云南绿之恋农业科技有限公司","before_cost_unit":390,"after_cost_unit":360,"diff_cost_unit":-30,"diff_cost_unit_percentage":-7.69,"before_gross_margin_percentage":21.69,"after_gross_margin_percentage":27.71,"diff_gross_margin_percentage":6.02},{"supply_id":"7bcc9770-e28b-45af-96e1-dbd15c337658","is_enabled":true,"supply_code":4410,"supply_name":"广州绿之恋农业科技有限公司","before_cost_unit":390,"after_cost_unit":360,"diff_cost_unit":-30,"diff_cost_unit_percentage":-7.69,"before_gross_margin_percentage":21.69,"after_gross_margin_percentage":27.71,"diff_gross_margin_percentage":6.02},{"supply_id":"8625f2f8-f661-490a-9e55-4aa1cae5a8a6","is_enabled":true,"supply_code":1504,"supply_name":"深圳市正禾蔬菜有限公司","before_cost_unit":390,"after_cost_unit":360,"diff_cost_unit":-30,"diff_cost_unit_percentage":-7.69,"before_gross_margin_percentage":21.69,"after_gross_margin_percentage":27.71,"diff_gross_margin_percentage":6.02},{"supply_id":"49481833-e099-4eaf-9c9b-ddf4c63fbe63","is_enabled":true,"supply_code":1396,"supply_name":"福州优野生态农业有限公司(佳素)","before_cost_unit":390,"after_cost_unit":360,"diff_cost_unit":-30,"diff_cost_unit_percentage":-7.69,"before_gross_margin_percentage":21.69,"after_gross_margin_percentage":27.71,"diff_gross_margin_percentage":6.02},{"supply_id":"0d55599b-c6a6-4896-99e5-09f9379b5c8b","is_enabled":false,"supply_code":1205,"supply_name":"福州耕韵生态农业开发有限公司","before_cost_unit":390,"after_cost_unit":360,"diff_cost_unit":-30,"diff_cost_unit_percentage":-7.69,"before_gross_margin_percentage":21.69,"after_gross_margin_percentage":27.71,"diff_gross_margin_percentage":6.02},{"supply_id":"fa417a5a-d275-44bf-895b-d03aae5b932e","is_enabled":true,"supply_code":4171,"supply_name":"遂宁市旭塘农业有限公司","before_cost_unit":390,"after_cost_unit":360,"diff_cost_unit":-30,"diff_cost_unit_percentage":-7.69,"before_gross_margin_percentage":21.69,"after_gross_margin_percentage":27.71,"diff_gross_margin_percentage":6.02}]
最新发布
07-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值