java - 为什么 Maven 失败并出现 SurefireExecutionException : > Cannot set option parallel with value

标签 java maven-2 testng surefire

您好,我正在使用 Windows XP 和最新版本完成本教程

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]
------------------------------------------------------------------------

最佳答案

来自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.

TestNG page 上有一个关于并行运行测试的部分插件文档。为此,您的 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>

关于java - 为什么 Maven 失败并出现 SurefireExecutionException : > Cannot set option parallel with value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1454908/

相关文章:

java - android 中的自定义 MediaPlayer 类

java - 混淆 – File f = new File(....); if(f.exists()) {…}

java - 在 JVM 启动时从 .jar 中的 .properties 文件设置属性

java - AndroMDA maven 代码生成和 JPA 注释

java - 测试框架意外退出、IntellijIdea、Java 和 TestNg 测试套件

testng - 如何确保 TestNG 在测试类上连续运行方法而不是交错运行?

java - 将复杂的 SQL 转换为 HQL?

java - 在 Sun-Grid Engine 上同时运行单个 JAR

maven - 如何从命令行获取属性值,如果不是从环境中获取,如果不是 - 默认值?

java - TestNG 软断言输出不全面