1、code is 200:断言 http 状态码为 200
pm.test(“Status code is 200”, function () {
pm.response.to.have.status(200);
});
2、contains string:断言响应结果包含指定的字符串
pm.test(“Body matches string”, function () {
pm.expect(pm.response.text()).to.include(“自定义指定字符串”);
});
3、json value check:检查 文中的 json 值
pm.test(“Your test name”, function () {
var jsonData = pm.response.json();
pm.expect(jsonData.value).to.eql(100); # 转json格式,检查value属性值为100
});
4、is equal to a string:断言响应结果等于指定的字符串
pm.test(“Body is correct”, function () {
pm.response.to.have.body(“指定的字符串”);
});
5、Content Type header check:断言 文头中是否包含 Content Type 字段
pm.test(“Content-Type is present”, function () {
pm.response.to.have.header(“Content-Type”);
});
6、response time is less than 200ms:断言接口响应时间小于 200ms
pm.test(“Response time is less than 200ms”, function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
7、Successful POST request:断言响应码在指定范围内,即 http 状态码在列表[201,202]中
pm.test(“Successful POST request”, function () {
pm.expect(pm.response.code).to.be.oneOf([201, 202]);
});
8、Code name has string:断言响应码包含指定的字符串,请求状态字符为OK
pm.test(“Status code name has string”, function () {
pm.response.to.have.status(“OK”);
});
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!