Search code examples
eclipsecucumber

gherkin.lexer.LexingError: Lexing error on line 1


When I run my first test file with Cucumber I got this exception How to solve this?

Exception in thread "main" cucumber.runtime.CucumberException: Error parsing feature file D:/intalled/CucumberConcepts/src/cucumber/features/myfeature.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:123)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:52)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:33)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:143)
at cucumber.runtime.Runtime.run(Runtime.java:107)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:16)

Caused by: gherkin.lexer.LexingError: Lexing error on line 1: 'Feature : Proof of concept that my framework works

This is my test file

Feature : Proof of concept that my framework works

Scenario Outline : My first Test
  Given this is my first test
  When This is my second step
  Then This is the final step

Solution

  • You need to do a couple of things: A) remove the spaces in Feature : and Scenario Outline : keywords; and B) change the Scenario Outline to Scenario (or add the missing examples for the outline).

    If you run this feature:

    Feature: Proof of concept that my framework works
    
    Scenario: My first Test
      Given this is my first test
      When This is my second step
      Then This is the final step
    

    Then cucumber will output the to-be-completed step definitions:

    You can implement step definitions for undefined steps with these snippets:
    
    Given(/^this is my first test$/) do
      pending # Write code here that turns the phrase above into concrete actions
    end
    
    When(/^This is my second step$/) do
      pending # Write code here that turns the phrase above into concrete actions
    end
    
    Then(/^This is the final step$/) do
      pending # Write code here that turns the phrase above into concrete actions
    end