2013-07-18 38 views
2

我试图并行运行测试方法。 testNG xml中的并行属性对我的执行没有影响。它们为所有四种可能的选项(方法,测试,类,实例)运行相同的方法.i.e我的方法对于所有四个选项都是顺序调用的,但我需要它们以并行方式运行。从here我明白“方法”选项应该为我工作。任何帮助?TestNG并行属性对方法执行没有影响

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 

} 

} 
+0

我从来没有使用parallel =方法,因为我从来没有观察到它做任何事情。然而,使用parallel = classes对我来说工作得很好。 – djangofan

回答

0

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

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