我正在使用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)
答案 0 :(得分:1)
我的猜测是你的黄瓜依赖版本与你的testng依赖版本不兼容,或者你还有其他的依赖冲突。