P R
P R

Reputation: 21

how to run all feature files multiple times with different values for one of the parameter

So far we have a configuration.properties where we set value for all required parameters, but I need to loop through multiple values for one of the parameters (probably comma delimited) and run all feature files for each.

Upvotes: 2

Views: 532

Answers (1)

Techno
Techno

Reputation: 101

I do not think there is a feature in cucumber to send multiple parameters to only one of the parameters. But what we can do is in the Scenario Outline,

  1. We can send the parameters comma separated
  2. The parameters to an array.
  3. Run the steps multiple times for that array

Feature file

Scenario Outline : Create User
 Given I enter names as <names>
 And I enter class as <class>
 When I click Save
 Then the success message is displayed

     Examples:
     |names      |class|
     |Ann,Malissa|5G   |

Step definition file

@Given("I enter names as (.*)")  
public void GivenIenterName(String names){
        String[] nameList = names.split("\\,");
         for(String x : nameList){
              /*block of code 
              to execute*/
         }
        }

Upvotes: 1

Related Questions