How to pass List of strings from Cucumber Scenario

Yogiraj picture Yogiraj · Jul 11, 2017 · Viewed 43.5k times · Source

I need to pass the List of strings from cucumber scenario which works fine as below

Scenario Outline: Verify some scenario 
Given something
When user do something 
Then user should have some "<data>" 
Examples: Some example
|data|
|Test1, Test2, Test3, Test4|

In the step definition I use List to retrieve the values of something variable. But when one of the value of data variable contains comma(,) e.g. Tes,t4 it becomes complex,since it considers "Tes" and "t4" as two different values

 Examples: Some example
 |something|
 |Test1, Test2, Test3, Tes,t4|  

So is there any escape character that i can use or is there is there any other way to handle this situation

Answer

SUMIT picture SUMIT · Nov 23, 2018

Found an easy way. Please see the below steps.

  • Here is my feature file.

    feature file

  • Here is the corresponding code to map feature step with code.

    code for the corresponding feature

  • Oh yes. Result is important. You can see the debug view.

    result in the debug view