httprunner中validate的比较方法总结
1、实际结果和期望结果是否相等:equals 或 eq 或 == 或 is
# 含义:check_value == expect_value
"validate": [
{"check":"check_value", "comparator": "eq", "expect": "expect_value"}
]
2、实际结果小于期望结果:less_than 或 lt
# 含义:check_value < expect_value
"validate": [
{"check":"check_value", "comparator": "lt", "expect": "expect_value"}
]
3、实际结果小于等于期望结果:less_than_or_equals 或 le
# 含义:check_value <= expect_value
"validate": [
{"check":"check_value", "comparator": "le", "expect": "expect_value"}
]
4、实际结果大于期望结果:greater_than 或 gt
# 含义:check_value > expect_value
"validate": [
{"check":"check_value", "comparator": "gt", "expect": "expect_value"}
]
5、实际结果大于等于期望结果:greater_than_or_equals 或 ge
# 含义:check_value >= expect_value
"validate": [
{"check":"check_value", "comparator": "ge", "expect": "expect_value"}
]
6、实际结果和期望结果不相等:not_equals 或 ne
# 含义:check_value != expect_value
"validate": [
{"check":"check_value", "comparator": "ne", "expect": "expect_value"}
]
7、实际结果和期望结果是否相等:string_equals 或 str_eq
# 含义:builtin_str(check_value) == builtin_str(expect_value)
"validate": [
{"check":"check_value", "comparator": "str_eq", "expect": "expect_value"}
]
8、实际结果的长度和期望结果是否相等:length_equals 或 len_eq 或 count_eq
# 含义:len(check_value) == expect_value
"validate": [
{"check":"check_value", "comparator": "len_eq", "expect": "expect_value"}
]
9、实际结果的长度大于和期望结果:length_greater_than 或 len_gt 或 count_gt 或 count_greater_than
# 含义:len(check_value) > expect_value
"validate": [
{"check":"check_value", "comparator": "len_gt", "expect": "expect_value"}
]
10、实际结果的长度大于等于期望结果:length_greater_than_or_equals 或 len_ge 或 count_ge 或 count_greater_than_or_equals
# 含义:len(check_value) >= expect_value
"validate": [
{"check":"check_value", "comparator": "len_ge", "expect": "expect_value"}
]
11、实际结果的长度小于期望结果:length_less_than 或 len_lt 或 count_lt 或 count_less_than
# 含义:len(check_value) < expect_value
"validate": [
{"check":"check_value", "comparator": "len_lt", "expect": "expect_value"}
]
12、实际结果的长度小于等于期望结果:length_less_than_or_equals 或 len_le 或 count_le 或 count_less_than_or_equals
# 含义:len(check_value) <= expect_value
"validate": [
{"check":"check_value", "comparator": "len_ge", "expect": "expect_value"}
]
13、实际结果包含期望结果:contains
# 含义:expect_value in check_value
"validate": [
{"check":"check_value", "comparator": "contains", "expect": "expect_value"}
]
14、实际结果被期望结果包含:contained_by
# 含义:check_value in expect_value
"validate": [
{"check":"check_value", "comparator": "contained_by", "expect": "expect_value"}
]
15、实际结果的字段类型和期望结果相同:type_match
# 含义:isinstance(check_value, get_type(expect_value))
"validate": [
{"check":"check_value", "comparator": "len_ge", "expect": "这个位置填写期望值的字段类型,例如:int,float,str,list,dic等等"}
]
16、检查实际结果和期望结果是否都是basestring的实例,如果都是就用正则匹配两个输入参数:regex_match
# 含义:
"validate": [
{"check":"check_value", "comparator": "regex_match", "expect": "这个位置用正则表达式填写期望结果"}
]
17、验证check_value是否已expect_value开始:startswith
# 含义:builtin_str(check_value).startswith(builtin_str(expect_value))
"validate": [
{"check":"check_value", "comparator": "startswith", "expect": "expect_value"}
]
18、验证check_value是否已expect_value结尾:endswith
# 含义:builtin_str(check_value).endswith(builtin_str(expect_value))
"validate": [
{"check":"check_value", "comparator": "endswith", "expect": "expect_value"}
]
参考文档:https://github.com/HttpRunner/HttpRunner/blob/master/httprunner/utils.py
https://github.com/HttpRunner/HttpRunner/blob/master/httprunner/built_in.py