In the case of dynamic scneario outline in karate, how can I pass a JSON array as well as another parameter in the examples for a scenario outline
I have the following JSON file :
Input.json:
{
"fieldList1": [
{
"datatype": "timestamp",
"fieldName": "DATE_"
},
{
"datatype": "decimal",
"fieldName": "DECIMAL_"
},
{
"datatype": "double",
"fieldName": "FLOAT_"
}
]
}
I'm reading this in my background as passing this as my Examples, in my scenario outline as follows:
TestScenario.feature:
Feature: scenario outline test
Background:
* def fieldListJson = call read(Input.json)
* def fieldList = karate.jsonPath(fieldListJson,$.fieldList1)[0]
Scenario Outline: Test
* def print <datatype>
* def print <fieldName>
Examples:
|fieldList|
I want to run this scenario for the fieldList against another set of parameters say
|Sources|
|oracle |
|sql |
|csvfile|
Would this be possible? I couldn't find any such example for the dynamic scenario outline to achieve such a scenario. Any suggestions please.
Solution 1:
The rule is it has to be an array. It is up to you what goes in that array.
a) There are many ways to transform existing data into the array "shape" that you want: https://stackoverflow.com/a/62833549/143475
b) use a data-driven call
instead of a Scenario Outline
, because then any variable defined is "visible" to the called feature: https://stackoverflow.com/a/69699486/143475