jeudi 27 septembre 2018

Validate array within an array case with BDD karate

Using the karate bdd plugin for automated testing cases along with cucumber. Facing a trouble validating an api structure having an array list within an array. How to validate the valuesets array in array structure with bdd karate?

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

Here is a piece of the code that I have been working on to accomplish this task.

* 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

Aucun commentaire:

Enregistrer un commentaire