gherkin icon indicating copy to clipboard operation
gherkin copied to clipboard

'And' keyword is not working, on commenting 'And' line the test works!

Open ankitagarwalnagarro opened this issue 3 years ago • 5 comments

What did you see? 👀

And keyword is not working, on comment And line the test works!

What did you expect to see? 😎

And keyword should also work like other keywords

Which version are you using? 🎁

io.cucumber cucumber-java 7.2.3 test io.cucumber cucumber-core 7.2.3 io.cucumber cucumber-testng 7.2.3 ## How could we reproduce it? 🔬

Use cucumber with java and testng

image

ankitagarwalnagarro avatar Feb 12 '22 18:02 ankitagarwalnagarro

Impossible to say without the actual text of the feature file.

mpkorstanje avatar Feb 12 '22 18:02 mpkorstanje

The actual text is:

And\t\tthe products api is called with <product> we have the list and fetch <product_id>

Because And isn't followed by a space ( ) Cucumber can't parse it.

mpkorstanje avatar Feb 12 '22 19:02 mpkorstanje

I would expect a parser to be lenient towards different space characters. However in this case the space is hardcoded into the keyword definition.

https://github.com/cucumber/common/blob/main/gherkin/gherkin-languages.json#L745

mpkorstanje avatar Feb 12 '22 19:02 mpkorstanje

Maybe, a parser post-processing task that normalizes the step and removes/replaces the TABULATORs with SPACEs (and maybe removes duplicated SPACEs) would be a good idea !?

BUT: The question is how often does this syndrome occur ?

jenisys avatar Feb 13 '22 09:02 jenisys

It is indeed weird; if we want to fix it I think we'd need to keep the whitespace (regex?) part of the Dialect/JSON rather than building it into the parser, as I'm not sure if all other languages use the same spacers to separate words:

(It may be an idea to make the keyword separator (:) part of the dialect too)

ciaranmcnulty avatar Feb 13 '22 11:02 ciaranmcnulty