mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 13:29:35 +08:00
refactor variable context:
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.
This commit is contained in:
@@ -1,10 +1,4 @@
|
||||
register_variables:
|
||||
variable_binds:
|
||||
- TOKEN: "debugtalk"
|
||||
- var: [1, 2, 3]
|
||||
- data: {'name': 'user', 'password': '123456'}
|
||||
|
||||
register_template_variables:
|
||||
bind_variables:
|
||||
variable_binds:
|
||||
- TOKEN: "debugtalk"
|
||||
- token: $TOKEN
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
- tests.data.custom_functions
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- json: {}
|
||||
- random: ${gen_random_string(5)}
|
||||
- authorization: ${gen_md5($TOKEN, $json, $random)}
|
||||
|
||||
- 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
|
||||
@@ -28,6 +27,8 @@
|
||||
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
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
gen_md5: "lambda *str_args: hashlib.md5(''.join(str_args).encode('utf-8')).hexdigest()"
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- data: ""
|
||||
- random: ${gen_random_string(5)}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
request:
|
||||
base_url: http://127.0.0.1:5000
|
||||
|
||||
@@ -19,6 +16,8 @@
|
||||
name: create user which does not exist
|
||||
variable_binds:
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- random: ${gen_random_string(5)}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
request:
|
||||
url: /api/users/1000
|
||||
method: POST
|
||||
@@ -35,6 +34,8 @@
|
||||
name: create user which does exist
|
||||
variable_binds:
|
||||
- data: '{"name": "user", "password": "123456"}'
|
||||
- random: ${gen_random_string(5)}
|
||||
- authorization: ${gen_md5($TOKEN, $data, $random)}
|
||||
- expected_status_code: 500
|
||||
request:
|
||||
url: /api/users/1000
|
||||
|
||||
Reference in New Issue
Block a user