yaml测试用例结构与关键字使用-get请求

get请求
  1.get请求不带参数

    /api/test/demo

  接口/get方法.py
import requests
S = requests.session()
r1 = S.request(method='GET',
               url='http://127.0.0.1:端口号/api/test/demo')
print(r1.text)

  接口/get_demo.yml

config:
    name: demo_case
teststeps:
-
    name: step1
    request:
        method: GET
        url: http://127.0.0.1:端口号/api/test/demo
    validate:
    - eq: [status_code, 200]
    - eq: [body.code, 0]
    - eq: [body.msg, 成功success!]
  2.get请求带参数
    /api/test/info?page=1&size=2
  接口/get方法.py
import requests
S = requests.session()
r2 = S.request(method='GET',
               url="http://127.0.0.1:端口号/api/test/info", 
         params
={ 'page': 1, 'size': 2 })
print(r2.text)
  接口/getparams.yml
config:
    name: get_params
teststeps:
-
    name: step-info
    request:
        method: GET
        url: http://127.0.0.1:端口号/api/test/info
    params:
        page: 1
        size: 2
    validate:
    - eq: [status_code,200]
    - eq: [body.code,0]
    - eq: [body.msg,success!]
posted @ 2022-05-19 14:26  乌醍  阅读(159)  评论(0编辑  收藏  举报