接口自动化yaml

version:
apiinface:
  - /login:
      description: 正确密码登录
      method: get
      headers: {name: bianchengbang,url: www.biancheng.net}
      request_data:
        type: json
        data:
            username: xiaoming
            password: 123456
      fetchdata:
        - type: jsonpath
          name: ${token}
          path: $..token
        - type: jsonpath
          name: ${user_id}
          path: $..token
  - /userinfo:
      description: 获取用户信息
      method: get
      headers:
        Admin-Token: ${token}
        Content-Type: application/json
      request_data:
        - type: parames
          data:
            user_id: ${user_id}
        - type: fields
        - type: data
        - data: json
      fetchdata:
        # 后置提取
        - type: jsonpath
          name: ${username}
          path: $..username
          # 后置提取
        - type: jsonpath
            name: ${code}
            path: $..code
        # 后置提取
        - type: re
          name: ${demo}
          path: $/{}/
#          如果类型是full,代表response数据
        - type: full
        - type: sql
          name: ${result}
          path: select usernmame username from user where user_id =${user_id}
        # 前置查询sql
        - type: pre_sql
          name: ${result}
          path: select usernmame username from user where user_id =${user_id}
      validate:
              - type: string_incluhe_string
                except: ${result}[0][0]
                res:  xiaoming
              - type: string_in_list
                except: ${result}[0]
                res: xiaoming
              - type: equal
                except: ${result}[0][0]
                res: xiaoming
                # 采用diff算法深度遍历
              - type: deepdiff
                except: ${result}[0][0]
                res: xiaoming
                ignore_order: True
                ignore_string_case: True

  

posted @ 2023-02-20 16:39  我是小菜鸡丫丫  阅读(42)  评论(0编辑  收藏  举报