3

I am trying to run a feature file which mentioned follows.

Feature: Prove the concept of my script

  Scenario: My first Test
    Given This is my first step
    When This is my second step
    Then This is my third step

and when I run this feature file, it give an error that says the follows and the steps have been highlighted with the statement of "Steps does not have a glue code."

The error is shown as below. I want to run the above feature file and get to know the missing files of the feature.

Exception in thread "main" java.lang.NoClassDefFoundError: gherkin/lexer/Encoding
    at cucumber.runtime.FeatureBuilder.read(FeatureBuilder.java:154)
    at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:115)
    at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:104)
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
    at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:235)
    at cucumber.runtime.Runtime.run(Runtime.java:110)
    at cucumber.api.cli.Main.run(Main.java:36)
    at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: gherkin.lexer.Encoding
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 9 more

Please, I am a starter to cucumber and I want to resolve this problem. Please help me if you can.

3 Answers3

2

Your exception tells me that you are missing a dependency.

I would clone https://github.com/cucumber/cucumber-java-skeleton or download it as a zip and get it up and running. This would hopefully tell what's wrong with your setup.

Thomas Sundberg
  • 4,098
  • 3
  • 18
  • 25
  • Hi Thomas, I downloaded the sample skeleton from above link but still my feature files fail to recognize the glue code. I have asked that here : https://stackoverflow.com/questions/57908884/unable-to-create-test-runner-class-in-cucumber-framework-due-to-error-in-resolvi?noredirect=1#comment102240716_57908884 – Kovid Mehta Sep 13 '19 at 10:42
0

This problem is happening because of missing of the encoding inside of gherkin in your eclipse set up. You have to install the latest version of gherkin. The latest available gherkin can be find from Marven repository. After downloading the latest version, import that gherkin jar file to the cucumber project.

Amila Sampath
  • 655
  • 4
  • 11
  • 28
0

Please add cucumber tags which starts with @ symbol Like below

@featureTest
Feature: Prove the concept of my script

@Scenario1
  Scenario: My first Test
    Given This is my first step
    When This is my second step
    Then This is my third step

Make sure the words in feature file matches "As is" in Step definition java file for Given, When and Then

Himadri
  • 150
  • 2
  • 11