cucumber-attic / gherkin

Cross platform parser for the Gherkin language. Used by Cucumber to parse .feature files.
252 stars 126 forks source link

Comma escaping #257

Closed vladgogit closed 7 years ago

vladgogit commented 7 years ago

I have this then statement: Then X Categories links are displayed: And this are my examples: |CategoriesItems| |asdfsfd ,safdasdfs, asdfsd, A, B&C| how i can use "A, B&C" as one parameter? Or if rewrite question how i can escape comma in examples?

enkessler commented 7 years ago

Any thing between | and | is passed to the step as a string. The only character that would need to be escaped is a | if you need to have one in your content. In other words: asdfsfd ,safdasdfs, asdfsd, A, B&C is already one, big parameter.

If you want to treat it as several parameters, you would need to split the string yourself in the step definition. For example. you could mark separate entries like |asdfsfd;safdasdfs;asdfsd;A, B&C| and then split on the ;.

vladgogit commented 7 years ago

I am sorry, i meant something a bit different. As you see i send a whole string but on java side i accept it as List of Strings and it is separating every item by COMMA. So i am asking how could i accept a parameter with comma inside it as one but not two parameters(which is actually happens) I checked and your solution doesn't work in my situation =(

enkessler commented 7 years ago

Ah. So this is a Java specific question? In that case, I recommend that you try asking on the relevant Gitter chat (https://gitter.im/cucumber/cucumber-jvm) or on the Google Group (https://groups.google.com/forum/#!forum/cukes). Also, this issue tracker is more for "I think there's a problem with the tool" questions and not "How do I do X" questions. So we should move this conversation to one of the other sites, anyway.

That being said, I've never used the Java version of Cucumber but, from what I am finding online, what type of object you try to create out of the String that Gherkin gives you is under your control based on how you declare the step definition. If you are having problems with the string auto-magically getting translated in a list of strings, I think that you can simply declare that you are expecting a string and then build the list yourself inside the step def.

vladgogit commented 7 years ago

ok. I am very sorry that i used this issue tracker as "How do I do X". It was out of desperation. But thank you anyway =)

enkessler commented 7 years ago

No worries. Hopefully one of those other forums will be more helpful than I was. :)