yaml测试用例结构与关键字使用-base_url
base_url
base_url是部署接口项目环境地址
部署环境地址和端口是有可能会变的
部署环境:包括http协议、ip或域名、端口8201(不写默认端口号80)
接口地址:只端口号后面的参数。例:/api/test/login
如果config中写了base_url,那么teststep只需写接口地址
接口/getbaseurl.yml
config:
name: getbaseurl
base_url: http://127.0.0.1:端口号
teststeps:
-
name: step-goods
request:
method: GET
url: /api/test/info
params:
page: 1
size: 2
validate:
- eq: [status_code,200]
- eq: [body.code,0]
- eq: [body.msg,success!]
如果有写绝对地址,那么些绝对地址的就用绝对地址
config: name: getbaseurl base_url: http://127.0.0.1:端口号 teststeps: - name: step-goods 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!] - name: step-goods request: method: GET url: http://127.0.0.1:端口号/api/test/info validate: - eq: [status_code,200] - eq: [body.code,0] - eq: [body.msg,success!]