【发布时间】:2018-05-03 07:36:12
【问题描述】:
我正在尝试在 POSTMAN 中进行测试,其中大小必须大于 0,但我无法正确进行测试。
我所做的是在大小小于 0 时使其失败。
邮递员有检查大小是否大于x个数的功能吗?
pm.test("Step 7/ Getting the resources and availabilites list " , function(){
pm.expect(pm.response.code).to.be.oneOf([200]);
if(pm.response.code === 200){
var jsonData = JSON.parse(responseBody);
var sizeOK= 1;
if(jsonData.resources.length>0){
}else{
//I will make the test fail if there is not data available on the response.
pm.test("Response body is empty ", function () {
pm.expect(pm.response.json().resources.length).to.equal(1);
});
}
console.log(Boolean(jsonData.resources.length>1))
}
});
【问题讨论】:
-
您要恢复哪种尺寸?来自响应正文中的元素?
-
我只希望它大于0,然后我将遍历列表。
标签: javascript postman