1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| access_ token接口将返回token放到变量中,并加断言 pm. test("响应状态码是200", function () { pm. response . to. have . status(200); }); pm. test("包含accesstoken",function () { pm. expect(pm. response . text()) . to. include("access_ .token"); }); pm. test("响应小于500ms",function () { pm. expect(pm. response . responseTime). to . be . below(500); });
var data = JSON. parse(responseBody);
var access_ token = data. access_ token;
pm. envi ronment . set(" access_ .token" ,access_ token); pm. test("过期时间为7200",function () { var jsonData = pm. response . json(); pm. expect(jsonData. expires. _in) . to . eq1(7200); });
|