mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-09 09:49:33 +08:00
fix: show assert value type when validation failed
This commit is contained in:
@@ -44,7 +44,7 @@ class TestCaseRequestMethodsWithFunctions(TestCaseRunner):
|
|||||||
{"eq": ["status_code", 200]},
|
{"eq": ["status_code", 200]},
|
||||||
{"eq": ["body.args.foo1", "session_bar1"]},
|
{"eq": ["body.args.foo1", "session_bar1"]},
|
||||||
{"eq": ["body.args.foo2", "session_bar2"]},
|
{"eq": ["body.args.foo2", "session_bar2"]},
|
||||||
{"eq": ["body.args.sum_v", "3"]}
|
{"eq": ["body.args.sum_v", 3]}
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
TestStep(**{
|
TestStep(**{
|
||||||
|
|||||||
@@ -27,34 +27,3 @@ teststeps:
|
|||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: ["body.args.sum_v", "3"]
|
- eq: ["body.args.sum_v", "3"]
|
||||||
- less_than: ["body.args.sum_v", "${sum_two(2, 2)}"]
|
- less_than: ["body.args.sum_v", "${sum_two(2, 2)}"]
|
||||||
-
|
|
||||||
name: post raw text
|
|
||||||
variables:
|
|
||||||
foo1: "hello world"
|
|
||||||
foo3: "$session_foo2"
|
|
||||||
request:
|
|
||||||
method: POST
|
|
||||||
url: /post
|
|
||||||
headers:
|
|
||||||
User-Agent: HttpRunner/${get_httprunner_version()}
|
|
||||||
Content-Type: "text/plain"
|
|
||||||
data: "This is expected to be sent back as part of response body: $foo1-$foo3."
|
|
||||||
validate:
|
|
||||||
- eq: ["status_code", 200]
|
|
||||||
- eq: ["body.data", "This is expected to be sent back as part of response body: session_bar1-session_bar2."]
|
|
||||||
-
|
|
||||||
name: post form data
|
|
||||||
variables:
|
|
||||||
foo1: bar1
|
|
||||||
foo2: bar2
|
|
||||||
request:
|
|
||||||
method: POST
|
|
||||||
url: /post
|
|
||||||
headers:
|
|
||||||
User-Agent: HttpRunner/${get_httprunner_version()}
|
|
||||||
Content-Type: "application/x-www-form-urlencoded"
|
|
||||||
data: "foo1=$foo1&foo2=$foo2"
|
|
||||||
validate:
|
|
||||||
- eq: ["status_code", 200]
|
|
||||||
- eq: ["body.form.foo1", "session_bar1"]
|
|
||||||
- eq: ["body.form.foo2", "bar2"]
|
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ class ResponseObject(object):
|
|||||||
except AssertionError:
|
except AssertionError:
|
||||||
msg += " - fail"
|
msg += " - fail"
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
raise ValidationFailure(f"assert {field}: {actual_value} {assert_method} {expect_value}")
|
actual_type = type(actual_value).__name__
|
||||||
|
expect_type = type(expect_value).__name__
|
||||||
|
raise ValidationFailure(f"assert {field}: {actual_value}({actual_type}) {assert_method} {expect_value}({expect_type})")
|
||||||
|
|
||||||
def extract(self, extractors: Dict[Text, Text]) -> Dict[Text, Any]:
|
def extract(self, extractors: Dict[Text, Text]) -> Dict[Text, Any]:
|
||||||
if not extractors:
|
if not extractors:
|
||||||
|
|||||||
Reference in New Issue
Block a user