Hi i am new to cucumber java. i am trying to run a simple cucumber feature test. below are my feature file, step definition file and junit runner file. but i am not able to
In Simple term, We need same jar version for cucumber-core,cucumber-java,cucumber-junit. To overcome this issue :)
Error, we are getting because of the jar files and corresponding version(not suitable for our JDK). I played with jar file - now issue is resolved. And also able to run and generate output.
My JDK version- 1.8.0_60 JARS, junit -4.12 cucumber-java-1.2.2.jar cucumber-junit-1.2.2.jar cucumber-core-1.2.2.jar gherkin-2.12.2.jar cucumber-jvm-deps-1.0.3.jar
Note: java,junit,core should be in same version. Remove unwanted cucumber jars. Debug by install only two(Java and Junit) jar files(different version) and try to resolve NoSuchMethod error.
I'm new and still learning. I had a similar 'cucumber runner initialization error' message:
java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptionsFactory.<init>(Ljava/lang/Class;[Ljava/lang/Class;)V
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:59)
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:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
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:26)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:87)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:73)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:46)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:522)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Referenced Libraries <= My Jars when I was having an error. I then replaced my cucumber-junit-1.1.5.jar with cucumber-junit-1.2.2.jar and the error message is now resolved. I can now run my cucumber junit test. I started with the latest jars but they seems to have issues. I then tried several different combination. I read 'rule of thumb' (also mentioned above) that the three jars (-core, -java and -junit) need to be of same version. Only then I was able to run my feature files and junit tests.
My current working jars are:
gherkin-2.12.2
cucumber-core-1.2.2
cucumber-java-1.2.2
cucumber-junit-1.2.2
cucumber-html-0.2.3
cucumber-jvm-deps-1.0.3
hamcrest-all-1.3
junit-4.11
selenium-server-standalone-3.13.0
I hope this helps.
The error means that cucumber.runtime.RuntimeOptions
has no constructor which takes a List
as argument.
Since all classes are part of cucumber, I suspect a bug in the release. Run mvn dependency:tree
and search the output for cucumber
. Make sure that you have only a single version of the dependency.
If your classpath is good, try an older version.
If that works, download the sources for cucumber and compile them. Does it work now? If so, open a bug report telling the Cucumber project that the latest release wasn't compile correctly.
gherkin-2.12.2 cucumber-core-1.2.2 cucumber-java-1.2.2 cucumber-junit-1.2.2 cucumber-html-0.2.3 cucumber-jvm-deps-1.0.3 hamcrest-all-1.3 junit-4.11 selenium-server-standalone-3.13.0
this worked for me and No Such method found error get resolved
i resolved similar issue by, keeping version of cucumber-junit
and cucumber-java
same.
Check your dependencies: Cucumber dependencies should be all aligned:
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.2</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>