空手道将CSV详细信息传递到另一个功能文件

问题描述 投票:1回答:1

这是我关于Stackoverflow的第一篇文章。请保持温柔。我有一个问题,即将一行从csv传递到一个称为功能文件。示例:

 Scenario: Reads the csv and triggers the bulk creation
  # Read the perfSelectors, creating a tabled array of JSON objects      
  * def perfSelectors = read ('perfSelectors.csv')

  # Call the bulk creation feature.  Call function should interact through each JSON array object from the CSV
  * call read('create-bulk-job.feature') perfSelectors

[在上面的示例中,空手道对csv(现在为JSON)中的行数进行计数,然后将ENTIRE JSON对象传递给行数。我只想要单行。

另一个例子:

Background:
  * def perfSelectors = read ('perfSelectors.csv')

Scenario Outline: Reads the csv and triggers the bulk creation

  # Call the bulk creation feature.  Call function should interact through each JSON array object from the CSV

  * call read('create-bulk-job.feature') { selectorType: '#selectorType' }

  Examples:
  |perfSelectors|

传递Null。...与行数相同。

我已经尝试了许多其他方法,但是它们大多以Null或传递整个有效负载的方式结束,但是始终正确计数CSV的行。

有什么建议吗?

karate web-api-testing
1个回答
0
投票

与整个行一样多次传递ENTIRE JSON对象。我只想要单行。

这没有道理。如果没有看到您的实际CSV,没有人可以提供帮助。当call的参数为JSON数组时,空手道将正确循环。

但是请记住,在“被调用”功能中,您始终可以访问在“调用”功能中定义的变量。由于__loop在范围上是magic variable,因此您可以执行以下操作:

* def row = perfSelectors[__loop]

如果您仍然遇到问题,请按照以下过程操作:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.