要检查响应主体是否包含字符串,可以使用以下命令:
tests["Body matches string"] = responseBody.has("string_you_want_to_search");
但是我有一个这样的responseBody:
{
"total": 20000,
"amount": {
"total": 10000,
"fees": 0,
"refunds": 0,
"liquid": 10000,
"currency": "BRL"
},
}
如何查看字段数量总计?
使用点运算符进行测试以访问嵌套值:
var data = JSON.parse(responseBody);
tests["10000"] = data.amount.liquid === "10000";
tests["BRL"] = data.amount.currency === "BRL";
希望能帮助到你!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句