2013-07-18 37 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>