pm.test("Status code is 200", function () { pm.response.to.have.status(200); });//判断响应码是否是200
pm.test("Body matches string", function () { pm.expect(pm.response.text()).to.include("string_you_want_to_search"); });//string_you_want_to_search 预期内容
pm.test("Body is correct", function () { pm.response.to.have.body("response_body_string"); });//response_body_string对响应返回的body内容校验,判断响应是否成功 pm.test("Your test name", function () { var jsonData = pm.response.json(); pm.expect(jsonData.value).to.eql(100); });
pm.test("Body is correct", function () { pm.response.to.have.body("response_body_string"); });//response_body_string 检查resonse body中是否包含某个string
pm.test("Content-Type is present", function () { pm.response.to.have.header("Content-Type"); });//Content-Type 检查response header中的Content-Type
pm.test("Response time is less than 200ms", function () { pm.expect(pm.response.responseTime).to.be.below(200); });//检查响应时间是否小于200ms
pm.test("Successful POST request", function () { pm.expect(pm.response.code).to.be.oneOf([201, 202]); });//POST 请求的状态响应码是否是某个值
pm.test("Status code name has string", function () { pm.response.to.have.status("ok"); });//状态码name值是否包含“OK”(如200ok)
var jsonObject = xml2Json(responseBody);//xml转json
原文:https://www.cnblogs.com/renxiaofan/p/14734219.html