yaml测试用例结构与关键字使用-post请求类型application/x-www-form-urlencoded
post请求类型application/x-www-form-urlencoded
示例:课程中的登录
接口/login_urlencode.yml
config:
name: login-test
base_url: http://127.0.0.1:端口号
teststeps:
-
name: step-login
request:
method: POST
# 去掉头部参数也可以,传data参数默认会生成headers带上的
# headers:
# Content-type: application/x-www-form-urlencoded
url: /api/test/login
data:
username: test
password: "123456"
config:
name: login-v4
base_url: http://127.0.0.1:端口号
teststeps:
-
name: step-login
request:
method: POST
# 传data参数,默认是application/x-www-form-urlencoded
# 传json参数,默认是application/json
# headers:
# Content-type: application/x-www-form-urlencoded
url: /api/v4/login
data:
username: test
password: "123456"
# json:
validate:
- eq: [status_code, 200]
- eq: [body.code, 0]
- eq: [body.msg, login success!]