【发布时间】:2021-04-09 05:14:21
【问题描述】:
我在循环 N 次中调用了该功能(有一些验证)。此代码有效并调用了我的功能 3 次。
* def xxx =
"""
function(times){
for(i=0;i<times;i++){
karate.call('classpath:api/test/hello.feature');
}
}
"""
* call xxx 3
在我调用的功能文件中,第一行代码是:
* def someVariable = 0;
* def index = response[someVariable]
* some other code
我需要 someVariable 根据 i 索引进行更改。例如,在循环中,第一次调用* def someVariable = 0;第二次调用* def someVariable = 1; 第三次调用* def someVariable = 2;
如何做到这一点?或者我可以在 JS 循环中添加这个变量吗?或者,也许可以使用 __loop (查看了示例,但无法实现它)。提前致谢。
【问题讨论】:
-
您可以尝试在调用功能文件时将索引作为参数传递
标签: javascript arrays iteration karate