Cucumber-jvm: Support for 'Examples' in Cucumber specification

Created on 5 Aug 2012  路  12Comments  路  Source: cucumber/cucumber-jvm

Feature file with 'Examples':

Feature: Hello Car

  Scenario: Car can drive
    Given I have a car
    When I add <wheels>
    Then It <can_drive>

  Examples:
  | wheels | can_drive |
  | 1 | false |
  | 2 | false |
  | 3 | false |
  | 4 | true |

Parser throws this error:

gherkin.parser.ParseError: Parse error at Car.feature:8. Found examples when expecting one of: comment, doc_string, row, scenario, scenario_outline, step, tag. (Current getState: step).
    at gherkin.parser.Parser$Machine.event(Parser.java:200)
    at gherkin.parser.Parser.event(Parser.java:152)
    at gherkin.parser.Parser.examples(Parser.java:117)
    at gherkin.lexer.i18n.EN.scan(EN.java:780)
    at gherkin.lexer.I18nLexer.scan(I18nLexer.java:30)
    at gherkin.parser.Parser.parse(Parser.java:57)
    at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:112)
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:40)
    at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:98)
    at cucumber.junit.Cucumber.<init>(Cucumber.java:61)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:43)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Most helpful comment

OP: You need to use 'Scenario Outline' in order to use 'Examples'.

All 12 comments

OP: You need to use 'Scenario Outline' in order to use 'Examples'.

I could have sworn I explained that when I closed this issue. Thanks for updating Matt

Thanks!

@mattwynne
Thanks It was very Useful.

@mattwynne Thank you!

@mattwynne excellent thanks!

@aslakhellesoy we really should try and improve the error message from Gherkin - I've seen this one soooo many times. Give me a pointer to where I would start the PR?

I think we should just allow Examples under Scenario, and make Scenario Outline a synonym. The first place to change would be in Gherkin's .berp grammar file. It would also require changes in the ASTs and compiler.

@mattwynne
Thanks It was very Useful. It resolves the issue.

thanks
It worked

@gabokr please open a new issue if you think you've found a bug. Add enough info so someone can reproduce it.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  8Comments

dherges picture dherges  路  4Comments

carlparziale picture carlparziale  路  10Comments

tcwmj picture tcwmj  路  10Comments

timp21337 picture timp21337  路  7Comments