1.检查请求后返回的状态码 status 为200
备注:status code:Code is 200
pm.test(“Status code is 200”, function () {
pm.response.to.have.status(200);
});
2.通过返回状态码检查是成功的post请求
备注:status code:successful POST request
pm.test(“Successful POST request”, function () {
pm.expect(pm.response.code).to.be.oneOf([201,202]);
});
3.检查response body等于指定字符串
备注:response body:is equal to a string
pm.test(“Body is correct”, function () {
pm.response.to.have.body("response_body_string");
});
4.检查response body中包含字符串
备注:response body:contains string
pm.test(“Body matches string”, function () {
pm.expect(pm.response.text()).to.include("string_you_want_to_search");
});
5.检查content-Type是否包含在header返回
备注: