-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Summary
When there is feature file with invalid comments or text the parser does not specify which file is causing the errors.
Expected Behavior
It would help if the parser error would specify which .feature file is affected.
Current Behavior
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
Possible Solution
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
Steps to Reproduce (for bugs)
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 |
Context & Motivation
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.
Your Environment
- Version used:
"io.cucumber:cucumber-java8:4.2.6"&"io.cucumber:cucumber-junit::4.2.6" - Operating System and version: macOS 10.13+
Running using gradle and cucumber CLI