yaml测试用例结构与关键字使用-valiables变量声明与引用

valiables变量声明与引用
  teststeps中变量对当前的step有效
  config中变量在整个yaml中都生效
  但如果config和teststeps中都有变量,那么 局部变量大于全局变量
  接口/login_var.yml
config:
    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]
posted @ 2022-05-19 15:39  乌醍  阅读(111)  评论(0编辑  收藏  举报