使用 BDD 空手道验证数组案例中的数组

Validate array within an array case with BDD karate

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

{
    "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'