yaml測試用例結構與關鍵字使用-get請求
阿新 • • 發佈:2022-05-19
get請求
1.get請求不帶引數
/api/test/demo
介面/get方法.pyimport 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",介面/getparams.yml
params={ 'page': 1, 'size': 2 })
print(r2.text)
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!]