postman使用技巧2
登录的接口tests中设置这些(上图所示),具体内容:
if(responseCode.code === 200){
tests["请求正常"] = responseCode.code === 200;
}else{
tests["请求正常异常【状态码为:200】"] = responseCode.code === 200;
}
try {
var responseJSON = JSON.parse(responseBody);
if(responseJSON.biz.code !== 200){
tests["业务错误【"+responseJSON.message.err_msg+"】"] = responseJSON.biz.code === 200;
}
else{
tests["业务正常"] = responseJSON.biz.code === 200;
//只有登录和获取header值才需要下面的三个赋值
postman.setEnvironmentVariable('t', responseJSON.biz.data.t);
postman.setEnvironmentVariable('s', responseJSON.biz.data.s);
}
}
catch (e) {
}
if(responseTime < 200){
tests["响应小于200毫秒【"+responseTime+"毫秒】"] = responseTime < 200;
}else{
tests["响应大于200毫秒【"+responseTime+"毫秒】"] = responseTime < 200;
}