[英]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:我有以下 JSON 文件:
Input.json:输入.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: 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我想针对另一组参数运行 fieldList 这个场景说
|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.
请有任何建议。
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 a)有很多方法可以将现有数据转换为您想要的数组“形状”: 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 b)使用数据驱动的
call
而不是Scenario Outline
,因为这样定义的任何变量对被调用的功能都是“可见的”: https://stackoverflow.com/a/69699486/143475
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.