我正在尝试基于黄瓜标签在Maven中运行一套Junit黄瓜功能。我可以让它们按顺序运行,但不能并行运行。 我找到了一个名为小胡瓜的程序包,该程序包应该可以帮我解决这个问题。
但是我无法运行测试,我看了github上的示例maven项目,它在Cucumber.class上运行正常,但在小胡瓜上抛出了错误。
任何帮助将不胜感激。
我在pom中包含了以下内容
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
<dependency>
<groupId>io.github.prashant-ramcharan</groupId>
<artifactId>courgette-jvm</artifactId>
<version>2.4.4</version>
<type>jar</type>
</dependency>
我正在这样称呼我的跑步者。
import courgette.api.CourgetteOptions;
import courgette.api.CourgetteRunLevel;
import courgette.api.junit.Courgette;
import cucumber.api.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Courgette.class)
@CourgetteOptions(
threads = 1,
runLevel = CourgetteRunLevel.FEATURE,
rerunFailedScenarios = false,
showTestOutput = true,
cucumberOptions = @CucumberOptions(features="src/test/resources/Features/Online/Regression/",
plugin={"html:target/OD.html","json:target/OD.json"
},tags={"@Max"},
glue="com.Online"
))
public class ONLINE_Regression_RunnerTest {
}
我遇到以下错误。
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at cucumber.runtime.io.ResourceLoaderClassFinder.loadClass(ResourceLoaderClassFinder.java:38)
at cucumber.runtime.io.ResourceLoaderClassFinder.getDescendants(ResourceLoaderClassFinder.java:26)
at cucumber.runtime.Reflections.instantiateSubclasses(Reflections.java:28)
at cucumber.runtime.Runtime.loadBackends(Runtime.java:99)
at cucumber.runtime.Runtime.<init>(Runtime.java:66)
at courgette.runtime.CourgetteFeatureLoader.createRuntime(CourgetteFeatureLoader.java:60)
at courgette.runtime.CourgetteFeatureLoader.<init>(CourgetteFeatureLoader.java:30)
at courgette.api.junit.Courgette.<init>(Courgette.java:39)
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:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
答案 0 :(得分:1)
请注意,Cucumber-jvm从v4.x开始提供并行选项
答案 1 :(得分:0)
通过将依赖关系移到pom的顶部,我能够消除冲突。 似乎与测试ng依赖项存在冲突。
答案 2 :(得分:0)
有N种方法(如下所述)可以实现并行执行,而最可取的方法之一是使用从V 4.0.0开始的Cucumber(特别是当我们必须仅在多个对象上实现并行执行时)浏览器不在多个操作系统上
为了实现4.0.0,请使用以下黄瓜依赖项集以及Maven配置,我们也将实现依赖项注入。
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>datatable</artifactId>
<version>1.1.12</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.3</version>
</dependency>
Maven Surefire配置-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire.plugin.version}</version>
<configuration>
<parallel>methods</parallel>
<threadCount>1</threadCount>
<reuserForks>false</reuserForks>
<testFailureIgnore>true</testFailureIgnore>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<includes>
<include>**/*RunCukeTest.java</include>
</includes>
</configuration>
</plugin>