-1

I would like to add the strings that I get in the steps from the cucumber feature to a list (without using .add for each string).

e.g., add the following strings in a list "string1","string2","string3"

Also, it would be nice if I can add on the cucumber feature to file more strings, and those will automatically be appended to the list.

I tried creating a table with Scenario Outline but no luck at the moment.

user812786
  • 4,302
  • 5
  • 38
  • 50

1 Answers1

1

Please find below feature file and step definitions. It will take the list of string in the cucumber table and add it to list without using .add.

Feature: Get the list of strings from table
Scenario: Get the list of strings
Given Get the strings from following table and print
|Value1|
|Value2|
|Value3|



@Given("^Get the strings from following table and print$")
public void get_the_strings_from_following_table_and_print(List<String> lstStr) throws Throwable {

    for(String str:lstStr)
        System.out.println(str);

}
Murthi
  • 5,299
  • 1
  • 10
  • 15