postman断言的方法

1.在test添加断言

2.检查response的body中是否包含字符串:

tests["Body matches string"] = responseBody.has("string_you_want_to_search");
tests["成功后展示的文案"] = responseBody.has("后台响应的文案"); 亲测ok

3.检查JSON的值:

var data = JSON.parse(responseBody);
tests["Your test name"] = data.value === 100;
var data = JSON.parse(responseBody);
tests["成功后展示的文案"] = data.字段 === 字段展示的值; 亲测ok

4.response的响应时间小于200ms:

tests["Response time is less than 200ms"] = responseTime < 200;

5.状态码为200:

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

来源: https://www.jianshu.com/p/61cfcb436ee4
posted @ 2018-09-26 21:39  凯宾斯基  阅读(1101)  评论(0编辑  收藏  举报