1

I want to assert values in json response from csv file. Is that possible in karate?

I have around 1200 codes in my response and I want to validate them against CSV file. I used read('Code.csv') but seems like it only works for single row. Do we need to add any iterator?

Code snippet:

  • def codeValue = karate.jsonPath(response, "$..code..CodeValue")
  • def codes_expected = read('Code.csv')
  • match codeValue contains only codes_expected

Response:

    {
  "code": {
    "AB": [
      {
        "CodeValue": "OI"
      }
    ],
    "CD": [
      {
        "CodeValue": "NO"
      },
      {
        "CodeValue": "CS"
      },
      {
        "CodeValue": "DE"
      }
    ],
    "TX": [
      {
        "CodeValue": "IO"
      },
      {
        "CodeValue": "ZC"
      },
      {
        "CodeValue": "FO"
      }
    ]
  }
}
Swati
  • 35
  • 3
  • to use csv, you may need to convert it to json and have more experience with karate. also refer: https://stackoverflow.com/a/62449166/143475 - and please search the documentation for "data driven" tests – Peter Thomas Apr 09 '21 at 14:56

0 Answers0