poatman添加断言

//检查返回状态code是否为200
tests["返回状态是否等于200"] = responseCode.code===200;
//判断请求到返回时间是否小于200毫秒
tests["返回时间是否小于200毫秒"] = responseTime < 200;
//将返回的body信息转换为JSON
var data = JSON.parse(responseBody);
//检查返回Body里面的isSuccess的值是否为true
tests["请求处理是否成功"] = data.isSuccess ===true;

//检查Content-Type是否包含在header返回
tests["Content-Type是否一起被返回"] = postman.getResponseHeader("Content-Type");

var schema = {//验证
"items":{
"type":"boolean"
}
};
tests["返回的isSuccess字段是否是bool类型"] = tv4.validate(data.isSuccess,schema);

猜你喜欢

转载自www.cnblogs.com/liuyh-blog/p/12559720.html