【发布时间】:2020-05-14 02:32:30
【问题描述】:
我想在 Postman 中编写一个测试来验证对象数组中没有重复值。这是一个示例响应:
{
"customerNumber": "123",
"customCategories": [
{
"customCategoryID": "1546",
"customCategoryDesc": "7100",
"itemNumbers": [
"7205",
"1834"
]
},
{
"customCategoryID": "1547",
"customCategoryDesc": "7130",
"itemNumbers": [
"2251",
"9832"
]
},
{
"customCategoryID": "1548",
"customCategoryDesc": "7315",
"itemNumbers": [
"1225541",
"1197233"
]
},
{
"customCategoryID": "1546",
"customCategoryDesc": "7100",
"itemNumbers": [
"7205",
"1834"
]
},
]
}
如您所见,“customCategoryID”:“1546”被重复;因此我希望测试失败并显示此响应,并显示重复的 customCategoryID 值(“1546”)。
我在这个question 和这个question 中查看了几个答案,但是需要使用 Postman 的最新测试脚本语法更新了他们的 JS 库以及对重复数据的断言。
非常感谢您的帮助。
【问题讨论】:
标签: validation duplicates automated-tests postman