2015-11-05 125 views
3

我一直在绕圈试图弄清楚这一点,似乎几乎不可能使用maven并行选项来对抗Selenium Grid群集。使用Maven Surefire进行并行Cucumber-JVM Selenium Grid测试

我的跑步者基于标签运行,应该选取5或6个功能文件。

我使用Cucumber for Java,使用Maven surefire 2.19和Junit。

到目前为止,我对POM万无一失的配置是这样的: -

<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运行: -

clean test -P RunFeature -D environmentName =“DEV” -Dcucumber.options =“ - tags @runnable --tags @ testa - tags @testb “

这是堆栈跟踪: -

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) 

我不知道在哪里可以从这里走。

+0

cucumber-jvm中的记者不是线程安全的,所以这不太可能。您可以尝试使用多个跑步者进行分组测试,并在课堂级别配置并行执行。 我感觉真的很冒险,你可以尝试这个重新实现黄瓜:https://github.com/jhorstmann/zuchini(免责声明:由我创建) 文档仍然缺乏,但它应该是主要兼容的,存储库中有一些示例。 –

+0

另一个更容易(而不是更好)的解决方案可能是使用多个写入不同报告的跑步者。每个功能文件都可以拥有自己的跑步者... – Dude

+0

看看http://stackoverflow.com/a/41100104/2895913详细解释。 –

回答

0

报告是尝试并行化时的一个实际问题。我们创建了一个名为zucchini的框架,它在并行测试执行和报告方面做了很多工作,并且与cucumber-jvm完全兼容。你可以看看它是否适用于你的应用程序

我们通过使用json报告器来解决报告问题,并允许每个并行线程创建自己的独立json对象。然后,我们将所有json结果汇总成一个'超级'json。你可以看到,代码here

相关问题