常用的postman断言 | 解释 | 对应脚本 |
Response body:Contains string | response包含字符串 | tests["Body matches string"] = responseBody.has("string_you_want_to_search"); |
Response body:Is equal to a string | response body等于指定字符串 | tests["Body is correct"] = responseBody === "response_body_string"; |
response body:JSON value check | json解析key的值进行校验 | tests["Your test name"] = jsonData.value === 100; |
status code:Code is 200 | 判断状态码 | tests["Status code is 200"] = responseCode.code === 200; |
status code:code name has string | 检查code name 是否包含内容 | tests["Status code name has string"] = responseCode.name.has("Created"); |