yaml測試用例結構與關鍵字使用-valiables變數宣告與引用
阿新 • • 發佈:2022-05-19
valiables變數宣告與引用
teststeps中變數對當前的step有效 config中變數在整個yaml中都生效 但如果config和teststeps中都有變數,那麼 區域性變數大於全域性變數 介面/login_var.ymlconfig:
name: 登入用例
variables:
user: test
psw: "123456"
teststeps:
-
name: step-登入
variables:
user: test1
psw: "123456"
request:
method: POST
url: http: //127.0.0.1:埠號/api/test/login
json:
username: $user
password: $psw
validate:
- eq: [status_code, 200]
- eq: [body.code, 0]- eq: [body.username, test]
- len_eq: [body.token, 40]
config:
name: 登入用例
variables:
user: test1
psw: "123456"
teststeps:
-
name: step-登入
# variables:
# user: test1
# psw: "123456"
request:
method: POST
url: http://127.0.0.1:埠號/api/test/login
json:
username: $user
password: $psw
validate:
- eq: [status_code, 200]
- eq: [body.code, 0]- eq: [body.username, $user]
- len_eq: [body.token, 40]
-
name: step-登入 test
request:
method: POST
url: http://127.0.0.1:埠號/api/test/login
json:
username: $user
password: $psw
validate:
- eq: [status_code, 200]
- eq: [body.code, 0]- eq: [body.username, $user]
- len_eq: [body.token, 40]