3

I tried to run cucumber multiple times with the use of Stackoverlow solutions solving this problem for others. It doesn't work for me.

The stacktrace I get running the runnerfile:

java.lang.NoSuchMethodError: cucumber.runtime.Runtime.<init>(Lcucumber/runtime/io/ResourceLoader;Lcucumber/runtime/ClassFinder;Ljava/lang/ClassLoader;Lcucumber/runtime/RuntimeOptions;)V

at cucumber.api.junit.Cucumber.createRuntime(Cucumber.java:80)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
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 com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Process finished with exit code -1

My POM file

<groupId>selenium-siebel-new</groupId>
<artifactId>selenium</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>2.43.1</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>2.53.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-ie-driver</artifactId>
        <version>2.43.1</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.0.0.RC14</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-jvm</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>2.43.1</version>
    </dependency>
</dependencies>
</project>

My runner java class:

@RunWith(Cucumber.class)
@CucumberOptions(
    features = "src/test/Resources/featurefiles",
    glue = "src/test/java/StepDefs/OpenSummaryPageStepDefs.java"
)
public class ChromeRunner {

private static ChromeDriverService service;

@BeforeClass
public static void createAndStartService() throws IOException {
    service = new ChromeDriverService.Builder()
            .usingDriverExecutable(new File    ("src/main/resources/drivers/chromedriver.exe"))
            .usingAnyFreePort()
            .build();
    service.start();

}
@AfterClass
public static void createAndStopService() {
    service.stop();
}
}

It would be nice if someone has a solution!:)

10
  • 1
    Can you check the version of cucumber-java 1.0.0.RC14? Are you sure about this? Guessing it should be similar to the others 1.2.5 Commented Dec 6, 2016 at 10:24
  • intellij added this version by itself, but changing to 1.2.5 seems to not solve it Commented Dec 6, 2016 at 10:46
  • Also the glue option you provided is not correct. You need to provide the java package instead of the actual path. in your case try something like "StepDefs" Commented Dec 6, 2016 at 10:55
  • @Grasshopper thanks for the tip! But still not able to run it. When I run the Junit example I had used from the internet (with before beforeclass test after -hooks then it is able to run. But since I try to use the RunWith it doesn't run. I combined the before/beforeclass I had with Junit to the Beforeclass and placed it within the runner class I have now Commented Dec 6, 2016 at 11:14
  • Well the error msg says that you do not have a constructor in Runtime class with the given parameters(resourceloader, classloader,classfinder,runtime options). I checked the code of this class in version 1.2.5 and it has this constructor. Do you have any old dependency of this such as multiple version in the hierarchy? Check the cucumber-core jar in which the class is present. Commented Dec 6, 2016 at 11:56

4 Answers 4

2

You should use the same version of Cucumber-java dependencies as the Cucumber-JVM and Cucumber-JUnit dependencies, that is 1.2.5 in POM.xml file. This should solve the problem.

   <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-jvm</artifactId>
        <version>1.2.5</version>
        <type>pom</type>
    </dependency>

    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.5</version>
        <scope>test</scope>
    </dependency>
Sign up to request clarification or add additional context in comments.

Comments

1

was facing same issue. for gradle using these two dependencies worked for me.

testCompile 'io.cucumber:cucumber-java:4.2.0'
testCompile 'io.cucumber:cucumber-junit:4.2.0'

Comments

0

I had the same issues as well and i was able to resolved the issue by changing all the info-cukes-cucumber dependencies to io.cucumber dependences

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.3.0</version>
</dependency>

   <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.3.1</version>
    <scope>test</scope>
</dependency>

Comments

0

Adding dependencies with same version solved my issue with #bobcat too

compile "io.cucumber:cucumber-java:4.2.6"
compile "io.cucumber:cucumber-java8:4.2.6"
compile "io.cucumber:cucumber-guice:4.2.6"
compile "io.cucumber:cucumber-junit:4.2.6"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.