java 为什么 Maven 因 SurefireExecutionException 失败:> 无法设置与值并行的选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1454908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is Maven failing with a SurefireExecutionException: > Cannot set option parallel with value
提问by Ric
Hi I am working through the tutorial here using windows XP and latest builds
嗨,我正在使用 Windows XP 和最新版本完成本教程
http://binil.wordpress.com/2006/12/08/automated-smoke-tests-with-selenium-cargo-testng-and-maven/
http://binil.wordpress.com/2006/12/08/automated-smoke-tests-with-selenium-cargo-testng-and-maven/
Could someone please tell me what the tags are.
谁能告诉我标签是什么。
<parallel>true</parallel>
<threadCount>10</threadCount>
When I build with these tags included I get a failure:
当我使用包含这些标签的构建时,我失败了:
-------------------------------------------------------
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]
------------------------------------------------------------------------
回答by Rich Seller
From the surefire-plugindocumentation:
来自surefire-plugin文档:
parallel(TestNG only) When you use the parallel attribute, TestNG will try to run all your test methods in separate threads, except for methods that depend on each other, which will be run in the same thread in order to respect their order of execution.
threadCount(TestNG only) The attribute thread-count allows you to specify how many threads should be allocated for this execution. Only makes sense to use in conjunction with parallel.
parallel(仅限TestNG)当您使用parallel 属性时,TestNG 将尝试在单独的线程中运行所有测试方法,但相互依赖的方法除外,这些方法将在同一线程中运行以尊重它们的执行顺序.
threadCount(仅限TestNG)属性thread-count 允许您指定应为此执行分配多少线程。只有与 parallel 结合使用才有意义。
There is a section on running tests in parallel on the TestNG pageof the plugin documentation. To do this your surefire plugin should be configured like this:
在插件文档的TestNG 页面上有一个关于并行运行测试的部分。为此,您的 surefire 插件应配置如下:
<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>
回答by Aaron Digulla
trueis not a valid value for the option parallel; try methods(as per the docs)
true不是选项的有效值parallel;尝试methods(根据文档)
回答by S. Ali Tokmen
This might also happen if you use an old version of TestNG.
如果您使用旧版本的 TestNG,也可能会发生这种情况。
Try upgrading your dependency to TestNG, for example:
尝试将您的依赖项升级到 TestNG,例如:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>5.11</version>
<classifier>jdk15</classifier>
<scope>test</scope>
</dependency>
PS: Many people would typically use version 5.1.
PS:很多人通常会使用 5.1 版。
Cheers
干杯
S. Ali Tokmen http://ali.tokmen.com/
S. Ali Tokmen http://ali.tokmen.com/

