HttpRunner(8):接口关联

关联

第一个test接口获取token,并提取出存储到变量中,在第二个test接口中直接调用该变量,如下图

# 接口关联
- config:
    name: 微信接口
    base_url: https://api.weixin.qq.com

- test:
    name: 获取token
    request:
      url: /cgi-bin/token
      method: GET
      params:
        grant_type: client_credential
        appid: wxf14419077f707856
        secret: 92a113bd4b5ffdc72144740dc7123c99
    extract:
      - token: content.access_token
      - time: content.expires_in
    validate:
      - eq: [$time,7200]


- test:
    name: 获取用户所有标签
    request:
      url: /cgi-bin/tags/get
      method: GET
      params:
        access_token: $token  # 引用上面的token实现关联
    extract:
      - id: content.tags.0.id
      - name: content.tags.0.name
    validate:
      - eq: [$id,2]
      - eq: [$name,"星标组"]

 

上一篇:android权限(转)


下一篇:HttpRunner介绍