2015-11-05 122 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

相關問題