mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 11:29:48 +08:00
TestRunner: run testcase writen in separate template
This commit is contained in:
62
test/data/demo_template_separate.yml
Normal file
62
test/data/demo_template_separate.yml
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
-
|
||||
name: create user which does not exist
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["$TOKEN", "$data", "$random"]}
|
||||
- expected_status_code: 201
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
response:
|
||||
status_code: "${expected_status_code}"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
|
||||
-
|
||||
name: create user which does not exist
|
||||
requires:
|
||||
- random
|
||||
- string
|
||||
- hashlib
|
||||
function_binds:
|
||||
gen_random_string: "lambda str_len: ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(str_len))"
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: {"func": "gen_random_string", "args": [5]}
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- authorization: {"func": "gen_md5", "args": ["$TOKEN", "$data", "$random"]}
|
||||
- expected_status_code: 500
|
||||
request:
|
||||
url: http://127.0.0.1:5000/api/users/1000
|
||||
method: POST
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
authorization: "${authorization}"
|
||||
random: "${random}"
|
||||
data: "${data}"
|
||||
response:
|
||||
status_code: "${expected_status_code}"
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
body:
|
||||
success: true
|
||||
msg: user created successfully.
|
||||
Reference in New Issue
Block a user