Java 使用Maven Surefire的并行网格测试
我一直在周而复始地试图弄明白这一点,在Selenium网格集群上使用cucumber和maven并行选项几乎是不可能的 我的跑步者根据标签跑步,应该会选择5到6个特征文件 我使用Cucumber for Java、Maven surefire 2.19和Junit 到目前为止,pom的surefire配置如下所示:-Java 使用Maven Surefire的并行网格测试,java,maven,selenium-webdriver,selenium-grid,cucumber-jvm,Java,Maven,Selenium Webdriver,Selenium Grid,Cucumber Jvm,我一直在周而复始地试图弄明白这一点,在Selenium网格集群上使用cucumber和maven并行选项几乎是不可能的 我的跑步者根据标签跑步,应该会选择5到6个特征文件 我使用Cucumber for Java、Maven surefire 2.19和Junit 到目前为止,pom的surefire配置如下所示:- <profile> <id>RunFeature</id> <build>
<profile>
<id>RunFeature</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<threadCount>5</threadCount>
<parallel>methods</parallel>
<systemProperties>
<property>
<name>environmentName</name>
</property>
</systemProperties>
<includes>
<include>**/RunFeature.java</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</profile>
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"json:target/cucumber.json"},
features = "classpath:",
glue = "classpath:",
dryRun = false,
strict = true)
public class RunFeature {
}
我和Maven一起跑步:-
清理测试-p RunFeature-D environmentName=“DEV”
-Dcucumber.options=“--tags@runnable--tags@testa--tags@testb”
这是stacktrace:-
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:287)
at com.sun.proxy.$Proxy17.feature(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.feature(JUnitReporter.java:165)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:69)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:387)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Feature: Buyer guidelines on buyer detailscucumber.runtime.CucumberException: Expected step: "I login to testing as "testingUser"" got step: "I switch to the "System" tab"
at cucumber.runtime.junit.JUnitReporter.fetchAndCheckRunnerStep(JUnitReporter.java:71)
at cucumber.runtime.junit.JUnitReporter.match(JUnitReporter.java:61)
at cucumber.runtime.Runtime.runStep(Runtime.java:278)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.runBackground(CucumberScenario.java:59)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:42)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:91)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:387)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:287)
at com.sun.proxy.$Proxy17.feature(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.feature(JUnitReporter.java:165)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:69)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:387)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
java.util.ConcurrentModificationException
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
at java.util.ArrayList$Itr.next(ArrayList.java:851)
at cucumber.runtime.RuntimeOptions$1.invoke(RuntimeOptions.java:287)
at com.sun.proxy.$Proxy17.uri(Unknown Source)
at cucumber.runtime.junit.JUnitReporter.uri(JUnitReporter.java:160)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:68)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:93)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:37)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:387)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
我不知道该从这里走到哪里。在尝试并行化时,报告是一个真正的问题。我们创建了一个名为的框架,它在并行测试执行和报告方面做了大量工作,并且完全兼容jvm。您可以检查它,看看它是否适用于您的应用程序
我们通过使用json reporter并允许每个并行线程创建自己的独立json对象来解决报告问题。然后,我们将所有json结果合并成一个“uber”json。您可以看到代码看看这个项目,它采用了不同的方法,但也可能是一个不错的选择:
这是Dude在2015年12月22日的评论中提出的解决方案的一种“干净”版本cucumber jvm中的记者并不是线程安全的,所以这是不容易做到的。您可以尝试使用多个运行程序对测试进行分组,并在类级别上配置并行执行。我觉得你真的很有冒险精神,你可以尝试重新实现cucumber:(免责声明:由我创建)文档目前仍然缺乏,但它应该基本兼容,存储库中有一些示例。另一个更简单(不是更好)的解决方案是使用多个运行程序编写不同的报告。每个功能文件都可以有自己的运行程序…请查看详细说明。