我尝试使用Stackoverlow解决方案多次运行黄瓜,为其他人解决了这个问题。它对我不起作用。
堆栈跟踪我运行了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)
处理以退出代码-1
结束我的POM文件
<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>
我的跑步者java课程:
@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();
}
}
如果有人有解决方案会很好!:)
答案 0 :(得分:1)
您应该使用与Cucumber-JVM和Cucumber-JUnit依赖项相同的Cucumber-java依赖项版本,即POM.xml文件中的1.2.5。这应该可以解决问题。
<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>
答案 1 :(得分:1)
面临同样的问题。 对于gradle,使用这两个依赖关系对我有用。
testCompile 'io.cucumber:cucumber-java:4.2.0'
testCompile 'io.cucumber:cucumber-junit:4.2.0'
答案 2 :(得分:0)
我也遇到了同样的问题,并且能够通过将所有info-cukes-cucumber依赖关系更改为io.cucumber依赖关系来解决该问题
<!-- 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>
答案 3 :(得分:0)
添加具有相同版本的依赖项也解决了#bobcat的问题
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"