testingkarate

Can we pass multiple tables from Examples Table to Scenario Outline?


I am reading the data from CSV file using the read("csv file path") method, and it works. Now there is a new requirement, and I need to pass the list of JSON objects (JSON array) in the scenario outline along with reading the file.

I tried below way. Keeping the jsonArray in CSV file is not a good idea I feel, so I do not want to keep the JSON array in CSV and want to pass the JSON array from the Example table.

   Examples:
      | read('classpath:Features/bulkdata/testdata/customer.csv') |

  | data  |                                                                          
  | [{"k1": "v1","k2": "v2","k3": "v3"},{"k4": "v4","k5": "v5","k6": "v6"}]                                                                                        |
  | [{"k7": "v8","k9": "v9","k10": "v10"}]                                                                                        |

is it possible in karate to pass the data from 2 sources (one from CSV file and another from Example table)


Solution

  • You can't have 2 "loop" data sources in a Scenario Outline.

    You can loop over JSON values defined in an Examples table: https://stackoverflow.com/a/60499447/143475

    Also refer:

    https://stackoverflow.com/a/78673358/143475

    https://stackoverflow.com/a/62449166/143475

    https://stackoverflow.com/a/70773725/143475

    https://stackoverflow.com/a/61685169/143475