將token接口中返回的access_token設置為全局變量。
如:token接口返回格式為:
{
"data": {
"access_token": "xxx",
"expires_in": xxx
},
"err": 0,
"msg": "success"
}
js腳本為:
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("Auth",jsonData.data.access_token);
test斷言:
tests["msg"] = jsonData.msg === "success";
tests["Status code is 200"] = responseCode.code === 200;

