Craig Flannagan
Craig Flannagan

Reputation: 609

Parse issues when trying to use "Examples" section in Cucumber feature

No luck in googling on this error message

features/manage_hand_evaluator.feature: Parse error at features/manage_hand_evaluator.feature:21. Found examples when expecting one of: comment, py_string, row, scenario, scenario_outline, step, tag. (Current state: step). (Gherkin::Parser::ParseError)

Here's the setup I have for Examples section (there are no other Scenarios at this time, just this one after the "Feature:" section)

...

Scenario: Evaluating for current straights
  Given I am a player with <hand>
  When the board is <board>
  Then the current possible straights should be <possibles>

  Examples:
    | board | hand |    possibles                  | 
    | A23   | 45   | A2345                         | 
    | 3456  | 23   | A2345,23456,34567,45678       | 
    | 789T  | A2   | 56789,6789T,789TJ,89TJQ       | 
    | 45678 | 23   | 23456,34567,45678,56789,6789T | 

I also have step definitions set up already for those "Given, When, Then" lines (and tests passes fine when I replace , , with some text and comment out the "Examples" section). So it seems step definitions are set up properly, just that there is some kind of parsing issue with the contents I have in .feature file and I cannot figure out what I am doing wrong.

Relevant gems installed: Gherkin (2.1.5) (tried 2.2.0 but it breaks with my version of Cucumber) Cucumber (0.8.5) Cucumber-Rails (0.3.2) Rails (2.3.8)

Upvotes: 31

Views: 16335

Answers (2)

Emjey
Emjey

Reputation: 2063

When you have tests that extends to having examples, you should always use Scenario Outline. Scenario is for those kind of tests with not more than one data to be inputted to test.

Upvotes: 3

AlistairH
AlistairH

Reputation: 3229

Replace

Scenario:

with

Scenario Outline:

Upvotes: 79

Related Questions