Files
httprunner/tests/data/demo_testcase_variables.yml
debugtalk 2ec2d3c2d8 make variables in testcase template compatible with mapping style:
new mapping style:
"variables": {
    "a": 1,
    "b": 2
}

Also, the former list style is still valid:
"variables": [
    {"a": 1},
    {"b": 2}
]
2018-11-28 12:14:06 +08:00

65 lines
1.8 KiB
YAML

- config:
name: "create user testcases."
variables:
device_sn: 'HZfFBh6tU59EdXJ'
base_url: ${get_base_url()}
- test:
name: get token
variables:
user_agent: 'iOS/10.3'
os_platform: 'ios'
app_version: '2.8.6'
sign: f1219719911caae89ccc301679857ebfda115ca2
request:
url: /api/get-token
method: POST
headers:
Content-Type: application/json
user_agent: $user_agent
device_sn: $device_sn
os_platform: $os_platform
app_version: $app_version
json:
sign: $sign
extract:
- token: content.token
validate:
- {"check": "status_code", "comparator": "eq", "expect": 200}
- {"check": "content.token", "comparator": "len_eq", "expect": 16}
- test:
name: create user which does not exist
variables:
user_name: "user1"
user_password: "123456"
request:
url: /api/users/1000
method: POST
headers:
Content-Type: application/json
device_sn: $device_sn
token: $token
json:
name: $user_name
password: $user_password
validate:
- {"check": "status_code", "comparator": "eq", "expect": 201}
- {"check": "content.success", "comparator": "eq", "expect": true}
- test:
name: create user which does not exist
request:
url: /api/users/1000
method: POST
headers:
Content-Type: application/json
device_sn: $device_sn
token: $token
json:
name: "user1"
password: "123456"
validate:
- {"check": "status_code", "comparator": "eq", "expect": 500}
- {"check": "content.success", "comparator": "eq", "expect": false}