2009-09-21 19 views
5

嗨,我經過這裏的教程工作使用Windows XP和最新的構建爲什麼Maven的有SurefireExecutionException失敗:>無法設置選項平行價值

http://binil.wordpress.com/2006/12/08/automated-smoke-tests-with-selenium-cargo-testng-and-maven/

可能有人請告訴我的標籤是什麼。

<parallel>true</parallel> 
<threadCount>10</threadCount> 

當我建立,這些標籤包括我得到一個錯誤:

------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running TestSuite 
org.apache.maven.surefire.booter.SurefireExecutionException: 
Cannot set option parallel with value 
true; nested exception is 
java.lang.reflect.InvocationTargetException: 
null; nested exception is 
org.apache.maven.surefire.util.NestedRuntimeException: 
Cannot set option parallel with value 
true; nested exception is 
java.lang.reflect.InvocationTargetException: 
null 
org.apache.maven.surefire.util.NestedRuntimeException: 
Cannot set option parallel with value 
true; nested exception is 
java.lang.reflect.InvocationTargetException: 
null 
java.lang.reflect.InvocationTargetException 
at 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method) at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at 
java.lang.reflect.Method.invoke(Method.java:585) 
at 
org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator$Setter.invoke(AbstractDirectConfigurator.java:117) 
at 
org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator.configure(AbstractDirectConfigurator.java:63) 
at 
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:71) 
at 
org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92) 
at 
org.apache.maven.surefire.Surefire.run(Surefire.java:177) 
at 
sun.reflect.NativeMethodAccessorImpl.invoke0(Native 
Method) at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at 
java.lang.reflect.Method.invoke(Method.java:585) 
at 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:338) 
at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:997) 
Caused by: 
java.lang.NullPointerException at 
org.testng.TestNG.setParallel(TestNG.java:347) 
... 15 more [INFO] 
------------------------------------------------------------------------ 
[ERROR] BUILD FAILURE [INFO] 
------------------------------------------------------------------------ 

回答

6

surefire-plugin文檔:

平行(TestNG的)當您使用並行屬性,TestNG會嘗試在單獨的線程中運行所有的測試方法,除了相互依賴的方法,它們將在同一個線程中運行以便響應等他們的執行順序。

threadCount(僅限TestNG)屬性線程數允許您指定應爲此執行分配多少個線程。結合平行使用纔有意義。

在插件文檔的TestNG page上有一段關於並行運行測試的部分。要做到這一點你的保命插件應配置是這樣的:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.4.2</version> 
    <configuration> 
    <parallel>methods</parallel> 
    <threadCount>10</threadCount> 
    </configuration> 
</plugin> 
1

如果您使用舊版本的TestNG,也可能發生這種情況。

嘗試升級您的依賴關係TestNG的,例如:

<dependency> 
    <groupId>org.testng</groupId> 
    <artifactId>testng</artifactId> 
    <version>5.11</version> 
    <classifier>jdk15</classifier> 
    <scope>test</scope> 
</dependency> 

PS:很多人通常會使用5.1版。

乾杯

S.阿里Tokmen http://ali.tokmen.com/

相關問題