【问题标题】:Why is Maven failing with a SurefireExecutionException: > Cannot set option parallel with value为什么 Maven 因 SurefireExecutionException 失败:> 无法设置与值并行的选项
【发布时间】:2009-09-21 14:51:22
【问题描述】:

您好,我正在使用 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]
------------------------------------------------------------------------

【问题讨论】:

    标签: java maven-2 testng surefire


    【解决方案1】:

    来自surefire-plugin 文档:

    parallel(仅限TestNG)当您使用parallel 属性时,TestNG 将尝试在单独的线程中运行您的所有测试方法,但相互依赖的方法除外,它们将在相同的线程,以尊重它们的执行顺序。

    threadCount(仅限TestNG)thread-count 属性允许您指定应为此执行分配多少线程。只有与并行一起使用才有意义。

    插件文档的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>
    

    【讨论】:

      【解决方案2】:

      true 不是选项parallel 的有效值;试试methods (as per the docs)

      【讨论】:

        【解决方案3】:

        如果您使用旧版本的 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。阿里托克曼 http://ali.tokmen.com/

        【讨论】:

          猜你喜欢
          • 2010-11-05
          • 1970-01-01
          • 1970-01-01
          • 2012-11-15
          • 2011-06-13
          • 1970-01-01
          • 1970-01-01
          • 2021-04-25
          • 2016-05-09
          相关资源
          最近更新 更多