简体   繁体   English

在空手道动态场景大纲的情况下,如何传递 JSON 数组以及场景大纲示例中的另一个参数

[英]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.

相关问题 如何在 Gherkin 的场景大纲中将示例表值嵌入到 Json 中 - How to embed an Example table values into Json in Scenario Outline in Gherkin 如何编写将 json 响应与场景大纲表进行比较的步骤定义 - How to write a step definition that compares a json response to a scenario outline table 如何在空手道中将 Json Object 转换为 Json 数组? - How can I convert to Json Object to Json Array in Karate? 如何从Ruby黄瓜方案大纲中生成可通过黄瓜报告正确使用的结果? - How to generate results from a Ruby Cucumber Scenario Outline that can be properly consumed by cucumber-reporting? 如何在空手道中为 json 数组设置动态值 - How to set a dynamic value for a json array in Karate 如何在Gherkin的Scenario outline中使用类似doc字符串的内容? - How to use something like a doc string in Scenario outline in Gherkin? 获取json文件的大纲 - Getting the outline of a json file 空手道:在一种情况下验证 json 和数组的密钥时遇到问题 - karate: getting issues validating keys for json & array in one scenario 有什么方法可以将场景大纲的每次迭代的响应保存到一个变量中,并将所有响应合并到一个 json 文件中 - Is there any way to save response of each iteration of Scenario Outline to a variable and consolidate all the responses into a single json file Axios给JSON添加常量名作为大纲,我怎么只发body呢? - Axios adds constant name as outline to JSON, how do I only send the body?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM