我有一个测试来检查响应数组的对象是1个月,3个月还是6个月等。
我已经创建了下面的测试,但是这些测试一直在通过,即使输入错误也是如此。
public ChromeOptions getChromeEmulators(int width, int height) {
Map<String, Object> deviceMetrics = new HashMap<String, Object>();
Map<String, Object> mobileEmulation = new HashMap<String, Object>();
ChromeOptions chromeOptions = new ChromeOptions();
try {
deviceMetrics.put("width", width);
deviceMetrics.put("height", height);
deviceMetrics.put("pixelRatio", 3.0);
mobileEmulation.put("deviceMetrics", deviceMetrics);
mobileEmulation.put("userAgent",
"Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D)
AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile
Safari/535.19");
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
}catch (Exception e) {
e.printStackStarce();
}
return chromeOptions;
}
和类似的东西
pm.test ("validate each object returns correct Frequency ", () => {
var fre = JSON.parse(responseBody);
for (i = 0; i < responseJson.length; i++){
pm.expect(fre[i].FREQUENCY) === (('1 Month') || ('3 Months') || ('6 Months') || ('1 Year rolling') || ('Since Inception'));
} });
并且也尝试过这种方式
pm.test ("validate each object returns correct Frequency ", function(){
pm.expect(responseJson.every((fre) => {
(fre.FREQUENCY) === ("1 Month") || ("3 Months") || ("6 Months") || ("1 Year rolling") || ("Since Inception");
})).to.be.true;
});
我的Json回复是这样的
pm.test ("validate each object returns correct Frequency ", function(){
pm.expect(responseJson.every((fre) => {
pm.expect(fre.FREQUENCY).to.be.oneOf === ("1 Month"),("3 Months"),("6 Months"),("1 Year rolling"),("Since Inception");
})).to.be.true;});
有人可以帮我吗?