mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-06 23:11:21 +08:00
#52: validator expect field support reference variable
This commit is contained in:
@@ -230,6 +230,8 @@ class Context(object):
|
|||||||
except exception.ParseResponseError:
|
except exception.ParseResponseError:
|
||||||
raise exception.ParseResponseError("failed to extract check item in response!")
|
raise exception.ParseResponseError("failed to extract check item in response!")
|
||||||
|
|
||||||
|
expect_value = self.testcase_parser.eval_content_variables(expect_value)
|
||||||
|
|
||||||
validator_dict = {
|
validator_dict = {
|
||||||
"check_item": check_item,
|
"check_item": check_item,
|
||||||
"check_value": check_value,
|
"check_value": check_value,
|
||||||
|
|||||||
@@ -11,11 +11,14 @@
|
|||||||
app_version: '2.8.6'
|
app_version: '2.8.6'
|
||||||
json:
|
json:
|
||||||
sign: f1219719911caae89ccc301679857ebfda115ca2
|
sign: f1219719911caae89ccc301679857ebfda115ca2
|
||||||
|
variables:
|
||||||
|
- expect_status_code: 200
|
||||||
|
- token_len: 16
|
||||||
extract:
|
extract:
|
||||||
- token: content.token
|
- token: content.token
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", $expect_status_code]
|
||||||
- len_eq: ["$token", 16]
|
- len_eq: ["$token", $token_len]
|
||||||
- len_eq: ["content.token", 16]
|
- len_eq: ["content.token", 16]
|
||||||
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
- {"check": "status_code", "comparator": "eq", "expect": 200}
|
||||||
- sum_status_code: ["status_code", 2]
|
- sum_status_code: ["status_code", 2]
|
||||||
|
|||||||
Reference in New Issue
Block a user