【问题标题】:TestNG parallel attribute has no effect on the method executionTestNG 并行属性对方法执行没有影响
【发布时间】:2013-07-18 06:17:37
【问题描述】:

我正在尝试并行运行测试方法。 testNG xml 中的 parallel 属性对我的执行没有影响。它们对所有四个可能的选项(方法、测试、类、实例)运行相同。即我的方法对所有四个选项按顺序调用。但我需要它们以并行方式运行。从here 我了解“方法”选项应该对我有用。有什么帮助吗?

TestNG xml 如下。

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
  <suite name="Test Suite" verbose="1" parallel="methods" thread-count="2">
     <test name="parallel">
        <classes>
          <class name="com.sample.A" />
        </classes>
     </test>
  </suite>

测试类如下

package com.sample;

Class A
{

@Test
public void abc() throws Exception

{
        // some code here

}

@Test
public void xyz() throws Exception

{
        //some code here

}

 }

【问题讨论】:

  • 我从不使用 parallel=methods ,因为我也从未观察到它做任何事情。不过,使用 parallel=classes 对我来说效果很好。

标签: java selenium-webdriver testng


【解决方案1】:
you can see the link
http://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html


this is my pom 
           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${testng.xml}</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>

【讨论】:

    【解决方案2】:

    同一个 TestNG 现在可以并行执行我的方法。问题是,尽管我更改了我的 xml,但 TestNG(在 Eclipse 中)运行配置保持不变。所以我已经更改为套件 XML。因此,在我的测试中反映的 XML 中所做的更改。感谢大家的宝贵时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-11
      • 1970-01-01
      • 1970-01-01
      • 2021-09-05
      • 2011-01-08
      • 1970-01-01
      • 2014-02-27
      • 2017-08-03
      相关资源
      最近更新 更多