mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-19 02:59:30 +08:00
1, variable context has two level, testset and testcase; 2, testset level variables can be used in whole test suite, while testcase level variables can only be used in testcase; 3, when variable binds with functions, the funtions will be called and the result will be set to the variable.
43 lines
1.4 KiB
YAML
43 lines
1.4 KiB
YAML
- config:
|
|
name: "create user testsets."
|
|
import_module_functions:
|
|
- tests.data.custom_functions
|
|
variable_binds:
|
|
- TOKEN: debugtalk
|
|
|
|
- test:
|
|
name: create user which does not exist
|
|
variable_binds:
|
|
- json: {"name": "user", "password": "123456"}
|
|
- random: ${gen_random_string(5)}
|
|
- authorization: ${gen_md5($TOKEN, $json, $random)}
|
|
request:
|
|
url: http://127.0.0.1:5000/api/users/1000
|
|
method: POST
|
|
headers:
|
|
Content-Type: application/json
|
|
authorization: $authorization
|
|
random: $random
|
|
json: $json
|
|
validators:
|
|
- {"check": "status_code", "comparator": "eq", "expected": 201}
|
|
- {"check": "content.success", "comparator": "eq", "expected": true}
|
|
|
|
- test:
|
|
name: create user which does not exist
|
|
variable_binds:
|
|
- json: {"name": "user", "password": "123456"}
|
|
- random: ${gen_random_string(5)}
|
|
- authorization: ${gen_md5($TOKEN, $json, $random)}
|
|
request:
|
|
url: http://127.0.0.1:5000/api/users/1000
|
|
method: POST
|
|
headers:
|
|
Content-Type: application/json
|
|
authorization: $authorization
|
|
random: $random
|
|
json: $json
|
|
validators:
|
|
- {"check": "status_code", "comparator": "eq", "expected": 500}
|
|
- {"check": "content.success", "comparator": "eq", "expected": false}
|