前言

一次在讲HttpRunner2.0时分层自动化是尝试在testcase层使用parameters关键字进行参数化,发现会报错,无法实现,
经了解发现HttpRunner2.0参数化只支持在testsuite套件中进行参数化。

示例

hrun —startproject httpbin
cd httpbin
  • api/httpbin_get.yaml
name: httpbin get接口
request:
  method: GET
  url: /get
  params:
    a: $a
    b: $b
  • testcases/test_get.yaml
- config:
    name: 测试get
    base_url: https://httpbin.org

- test:
    name: Step1-测试get
    api: api/httpbin_get.yaml

经测试testcases层使用作者PPT中的config: ... teststeps: - ...格式会有问题,使用HttpRunner1.0版本的-config: ... -test: ...格式正常。

  • testsuites/suite1.yaml
config:
  name: 示例测试套件

testcases:
  正常添加加油卡:
    testcase: testcases/test_get.yaml
    parameters:
      a-b:
        - [1, 2]
        - [3, 4]

运行方式,从suite1处运行

hrun testsuites/suite1.yaml

相关文章:

  • 2021-04-22
  • 2021-05-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-15
  • 2021-12-17
  • 2022-02-02
猜你喜欢
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2022-01-12
相关资源
相似解决方案