Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeatureParser does not report affected file on ParserException$CompositeParserException #1607

Closed
nicodn opened this issue Apr 8, 2019 · 2 comments

Comments

@nicodn
Copy link

nicodn commented Apr 8, 2019

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

@mpkorstanje
Copy link
Contributor

Cheers. Was already fixed by #1600.

@lock
Copy link

lock bot commented Apr 15, 2020

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.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants