Call feature in a loop and have one variable in the called feature as iteration number

I am calling the feature (which has some validations) in the loop N number of times. This code works and calls my feature 3 times.

* def xxx =
    """
      function(times){
         for(i=0;i<times;i++){
          karate.call('classpath:api/test/hello.feature');
        }
      }
    """

* call xxx 3

In the feature file I am calling, first line of code is:

* def someVariable = 0;
* def index = response[someVariable]
* some other code

I need someVariable to change based on the i index. For example, in the loop, first time feature is called * def someVariable = 0;Second time it is called * def someVariable = 1; Third time it is called * def someVariable = 2;

How can this be achieved? Or can I add this variable inside the JS loop? Or, maybe __loop can be used (looked at the examples, but was not able to implement it). Thanks in advance.



Read more here: https://stackoverflow.com/questions/67015403/call-feature-in-a-loop-and-have-one-variable-in-the-called-feature-as-iteration

Content Attribution

This content was originally published by karateKid at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: