其他分享
首页 > 其他分享> > 2021-04-30postman使用技巧2(新写法)

2021-04-30postman使用技巧2(新写法)

作者:互联网

if(responseCode.code === 200){

    tests["请求正常"] = responseCode.code === 200;

}else{

    tests["请求正常异常【状态码为:200】"] = responseCode.code === 200;

}

try {

    var responseJSON = JSON.parse(responseBody); 

    if(responseJSON.code !== 200){

     tests["业务错误【"+responseJSON.message+"】"] = responseJSON.code === 200;

    }

    else{

        tests["业务正常"] = responseJSON.code === 200;

        tests["t---【"+responseJSON.data.t+"】"] = true;

       //只有登录和获取header值才需要下面的三个赋值

        postman.setEnvironmentVariable('t', responseJSON.data.t);

        postman.setEnvironmentVariable('s', responseJSON.data.s);

    }

}

catch (e) { 

}

if(responseTime < 200){

    tests["响应小于200毫秒【"+responseTime+"毫秒】"] = responseTime < 200;

}else{

    tests["响应大于200毫秒【"+responseTime+"毫秒】"] = responseTime < 200;

}

标签:200,tests,responseJSON,04,毫秒,code,30postman,2021,responseTime
来源: https://blog.csdn.net/bear_79/article/details/116304381