首页 > 其他 > 详细

postman之tests常用方法

时间:2021-05-06 15:10:19      阅读:53      评论:0      收藏:0      [点我收藏+]
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

 

postman之tests常用方法

原文:https://www.cnblogs.com/renxiaofan/p/14734219.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!