gpt4 book ai didi

api - 使用 BDD Karate 验证数组案例中的数组

转载 作者:行者123 更新时间:2023-11-28 20:36:28 29 4
gpt4 key购买 nike

将 karate bdd 插件与 cucumber 一起用于自动化测试用例。在验证数组中包含数组列表的 api 结构时遇到问题。如何使用 bdd Karate 验证数组结构中的 valuesets 数组?

{
"reqParam": "5bacfbaaa222ed1500f5aa7a",
"selectionLimit": [],
"valuesets": [
[{
"test": "sample",
"testB": "sample"
},
{
"test": "sample",
"testB": "sample"
},
{
"test": "sample",
"testB": "sample"
}
],
[{
"test": "sample",
"testB": "sample"
},
{
"test": "sample",
"testB": "sample"
}
]
]
}

这是我一直致力于完成此任务的一段代码。

* def samplePacket = { test: '#string', testB: '#string'}
Scenario: Check the valid params
Given url API_URL
Given path 'getParam/apicall'
And params validParameter
When method get
Then status 200
And match header Content-Type == 'application/json; charset=utf-8'
#And print response.valuesets[0]
Then match each response.valuesets == #[] samplePacket

最佳答案

您有多层嵌套数组。

* def valueset = { test: '#string', testB: '#string' }
* def setarray = '#[] valueset'
* match response.valuesets == '#[] setarray'

关于api - 使用 BDD Karate 验证数组案例中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52540969/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com