postman断言使用

Postman使用

1)基础篇

1.常规断言-断言tests

Tests 为执行断言后的测试结果

tests["Body matches string"] = responseBody.has("2018-05-15");

测试返回的状态码

tests["Status code is 200"] = responseCode.code === 200;

测试返回的状态信息

测试响应时间是否低于200ms

检查响应body中等于指定string

tests["Body is correct"] = responseBody === "response_body_string";

检查Content-Type 是否包含在header返回(大小写不敏感)

tests["Content-Type is present"] = postman.getResponseHeader("Content-Type");

检查成功post请求,或可以接着往下走

tests["Successful POST request"] = responseCode.code === 201 || responseCode.code === 202;

posted on 2024-07-19 13:41  韩文星  阅读(26)  评论(0)    收藏  举报