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