When there is feature file with invalid comments or text the parser does not specify which file is causing the errors.
It would help if the parser error would specify which .feature file is affected.
Currently this is the exception produced:
Exception in thread "main" cucumber.runtime.CucumberException: gherkin.ParserException$CompositeParserException: Parser errors:
(13:5): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got 'Examples:'
at cucumber.runtime.model.FeatureParser.parseResource(FeatureParser.java:40)
at cucumber.runtime.model.FeatureBuilder.parse(FeatureBuilder.java:36)
at cucumber.runtime.model.FeatureLoader.loadFromFeaturePath(FeatureLoader.java:49)
at cucumber.runtime.model.FeatureLoader.load(FeatureLoader.java:36)
at cucumber.runtime.model.FeatureLoader.load(FeatureLoader.java:22)
at cucumber.runtime.FeaturePathFeatureSupplier.get(FeaturePathFeatureSupplier.java:23)
at cucumber.runtime.Runtime.run(Runtime.java:67)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:8)
Caused by: gherkin.ParserException$CompositeParserException: Parser errors:
(13:5): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got 'Examples:'
at gherkin.Parser.parse(Parser.java:143)
at gherkin.Parser.parse(Parser.java:118)
at gherkin.Parser.parse(Parser.java:114)
at cucumber.runtime.model.FeatureParser.parseResource(FeatureParser.java:36)
... 8 more
Discussed this on slack:
https://cucumberbdd.slack.com/archives/C60TKS3SL/p1553896025057000?thread_ts=1553895232.056500&cid=C60TKS3SL
@mpkorstanje suggested the fix might go in here:
https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/runtime/model/FeatureParser.java#L40
Example (invalid) feature file:
# Comment
@tag
Feature: Eating too many cucumbers may not be good for you
Eating too much of anything may not be good for you.
Scenario: Eating a few is no problem
Given Alice is hungry
When she eats 3 cucumbers
Then she will be full
# Not allowed:
Examples:
| start | eat | left |
| 12 | 5 | 7 |
We're looking at adding multiple feature files at a time in a medium sized QA team and this would help out quite a bit. In the meantime I've added a dry-run PR check that helps mitigate these parsing issues from getting into production.
"io.cucumber:cucumber-java8:4.2.6" & "io.cucumber:cucumber-junit::4.2.6"Running using gradle and cucumber CLI
Cheers. Was already fixed by #1600.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Cheers. Was already fixed by #1600.