Error while running cucumber in junit

前端 未结 6 1185
[愿得一人]
[愿得一人] 2021-01-19 01:18

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

6条回答
  •  无人共我
    2021-01-19 01:40

    I'm new and still learning. I had a similar 'cucumber runner initialization error' message:

    java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptionsFactory.(Ljava/lang/Class;[Ljava/lang/Class;)V
        at cucumber.api.junit.Cucumber.(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.

提交回复
热议问题