maven 执行cucumber-jvm + testNG时出现配置错误?

l3zydbqr  于 2023-02-11  发布在  Maven
关注(0)|答案(2)|浏览(179)

我使用cucumber-jvm + testNg + Maven来运行我的测试用例。

@RunWith(Cucumber.class)
   @Cucumber.Options(
       format={"pretty", "json:target/report.json"},
       features = "classpath:cucumber/Login.feature",   
       glue = "stepDefinitions",
       tags="@login,@AB,@close"

       )
  public class RunCukesTest extends AbstractTestNGCucumberTests{  }

执行测试用例的Maven命令。

mvn test

我得到这个错误

Configuring TestNG with:  org.apache.maven.surefire.testng.conf.TestNG652Configurator@3eec1a
      Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.437 sec <<< FAILURE!
      run_cukes(runner.RunCukesTest)  Time elapsed: 0.015 sec  <<< FAILURE!
      java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptionsFactory.<init>(Ljava/lang/Class;)V
      at cucumber.api.testng.TestNGCucumberRunner.<init>  (TestNGCucumberRunner.java:29)
      at Cucumber.api.testng.AbstractTestNGCucumberTests.run_cukes(AbstractTestNGCucumber          Tests.java:14)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.MethodInvocationHelper$1.runTestMethod(MethodInvocationHelpe       r.java:200)
     at Cucumber.api.testng.AbstractTestNGCucumberTests.run(AbstractTestNGCucumberTests.java:19)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.testng.internal.MethodInvocationHelper.invokeHookable(MethodInvocationHelper.java:212)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:707)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
ncecgwcz

ncecgwcz1#

我猜您的cubble依赖项版本与testng依赖项版本不兼容,或者您有一些其他的依赖项冲突。

gab6jxml

gab6jxml2#

1.从junit4中删除@RunWith(Cucumber.class)-
1.从测试导入 cucumber 选项导入io. cucumber .测试 cucumber 选项;
有关详细信息,请参阅此文档Link

相关问题