while running cucumber as per the code in JUnit Test Runner Class

i am getting below errors after added all the cucumber jars

java.lang.NoClassDefFoundError: gherkin/formatter/Formatter
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
at cucumber.runtime.formatter.PluginFactory$1.<init>(PluginFactory.java:53)
at cucumber.runtime.formatter.PluginFactory.<clinit>(PluginFactory.java:52)
at cucumber.runtime.RuntimeOptions.<init>(RuntimeOptions.java:69)
at cucumber.runtime.RuntimeOptionsFactory.create(RuntimeOptionsFactory.java:25)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:55)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: gherkin.formatter.Formatter
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)
… 35 more

anandhi Default Asked on February 14, 2016 in Selenium WebDriver.
Add Comment
5 Answer(s)

You have not included all the jar files in the project. Please check again.

Virender

Virender Singh Professor Answered on February 14, 2016.
Add Comment

I am using the jar files as seen in the screen shot…but still getting error
i have also added rest of the JAR files. 
RE: while running cucumber as per the code in JUnit Test Runner Class

Mohit Default Answered on March 16, 2016.
Add Comment

The Problems it’s not related with the Jar files, I spend tow days searching for a solution, until i have to restart the whole process to find the problem.

When you glue the Test_Steps.java and the feature file, you have be very careful with the path that you’re using, i did this to fix it.

RE: while running cucumber as per the code in JUnit Test Runner Class
DanielT007 Default Answered on April 30, 2016.
Add Comment

Hello,
I have created the testrunner class and the features file, like on the web page but when I execute the test appears the same error.
I have also the same jars and I check that the path of the files are correct.

RE: while running cucumber as per the code in JUnit Test Runner Class
RE: while running cucumber as per the code in JUnit Test Runner Class
RE: while running cucumber as per the code in JUnit Test Runner Class

Any one can know how can I fix this error?
Thanks in advance

jnavio17 Default Answered on June 7, 2016.
Add Comment

This problem went away for me when I changed the gherkin jar file in the build path for the project to gherkin-2.12.jar.  Check out the 1 answer to this post in Stack Overflow.

http://stackoverflow.com/questions/36771066/java-lang-noclassdeffounderror-exception-while-running-cucumber-test-using-junit

With luck, you should  be able to get gherken-2.12.jar from here:

http://mvnrepository.com/artifact/info.cukes/gherkin/2.12.2

PaulK Default Answered on October 10, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.