简体   繁体   English

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

[英]Karate passing csv details to another feature file

This is my first post on Stackoverflow.这是我在 Stackoverflow 上的第一篇文章。 Be gentle please.请温柔一点。 I have a question around passing in a row from a csv to a called feature file.我有一个关于从 csv 连续传递到调用功能文件的问题。 Examples:例子:

 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

In the example above, Karate counts the number of rows in the csv (now JSON) then passed the ENTIRE JSON object as many times as there are rows.在上面的示例中,空手道计算 csv(现在是 JSON)中的行数,然后通过 ENTIRE JSON object 的次数与行数一样多。 I just want the single row.我只想要单行。

Another example:另一个例子:

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|

Passes Null....as many times as there are rows.通过 Null....与行数一样多。

I have tried many other approaches but they largely end up either Null or passing the entire payload, but always correctly counting the rows of the CSV.我尝试了许多其他方法,但它们在很大程度上最终要么 Null 要么传递整个有效负载,但始终正确计算 CSV 的行数。

Any suggestions?有什么建议么?

passed the ENTIRE JSON object as many times as there are rows.通过 ENTIRE JSON object 的次数与行数一样多。 I just want the single row.我只想要单行。

This doesn't make sense.这没有意义。 And no one can help without seeing your actual CSV.如果没有看到您的实际 CSV,任何人都无法提供帮助。 Karate will loop correctly when the argument to a call is a JSON array.call的参数是 JSON 数组时,空手道将正确循环。

But keep in mind that in a "called" feature, you can always access the variables defined in the "calling" feature.但请记住,在“调用”功能中,您始终可以访问“调用”功能中定义的变量。 Since __loop is a magic variable in scope, you can do this:由于__loop是 scope 中的魔术变量,因此您可以这样做:

* def row = perfSelectors[__loop]

If you are still stuck, please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue如果您仍然卡住,请按照以下流程操作: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 空手道:将变量从一个特征文件传递到另一个作为查询参数 - Karate : Passing variable from one feature file to another as a query parameter 空手道 API 测试 - 将变量从一个特征文件传递到另一个 - Karate API Testing - Passing variable from one feature file to another 在空手道中将变量从一个特征文件传递到另一个特征文件作为请求 URL(不是查询参数)的一部分 - Passing a variable from one feature file into another as a part of request URL(not query parameter) in Karate 在从空手道中的另一个功能中调用场景时传递参数? - Passing parameters while calling a scenario from another feature flie in karate? 如何在空手道的单个功能文件中使用两个或多个 csv 文件? - How to use two or more csv file in a single feature file in karate? Karate-afterFeature - 主要特征文件不能使用 Karate-afterFeature 调用另一个特征文件 - Karate-afterFeature - main feature file cannot call another feature file using Karate-afterFeature 空手道 API:将变量传递给其他功能文件不起作用 - Karate API : Passing variables to other feature file is not working 空手道-从另一个特征文件中的响应中获取字段的值 - Karate- get value of a field from response in another feature file 空手道 API 框架 - 在另一个功能文件中调用 function - Karate API Framework - Calling function in another feature file 空手道-如何从响应/通过运行另一个功能文件获取数据 - KARATE - How to get data from response/by running another feature file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM