2015-04-07 70 views
1

我在我的測試中使用@Parameters("DeviceModel") 我通過testNG.xml文件運行並行3個線程。 在TestNG.XML中,我傳遞3個參數。與Maven並行運行TestNG測試並通過Maven傳遞參數

1-st parameter: <parameter name="DeviceModel" value="devicemodel1"> 
2-nd parameter: <parameter name="DeviceModel" value="devicemodel2"> 
3-rd parameter: <parameter name="DeviceModel" value="devicemodel3"> 

當的testng.xml正在執行它需要1-ST PARAM爲線程1,2-ND PARAM螺紋2和3 rd進行螺紋3. 因此我得到與每個不同PARAMS 3個並行線程。

現在我想通過使用TestNG的Maven SureFire插件進行並行測試。 我通過在pom.xml中

<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-surefire-plugin</artifactId> 
<version>2.18.1</version> 
<configuration> 
<parallel>tests</parallel> 
<threadCount>3</threadCount> 
<includes> 
<include>packageName/*Test.java</include> 
</includes> 
<systemPropertyVariables> 
<DeviceModel>devicemodel1</DeviceModel> 
<DeviceModel>devicemodel1</DeviceModel> 
<DeviceModel>devicemodel1</DeviceModel> 
</systemPropertyVariables> 
</configuration> 

以下值這是行不通的。 我的測試僅對每個線程執行第三個參數。 我怎麼可以傳遞3個不同的參數給TestNg 3個並行線程與maven?

回答

0

有可能繼續使用的testng.xml也與Maven。

在這個例子中套件文件的testng.xml位於的src /測試/資源子目錄:

<build> 
    <testResources> 
     <testResource> 
      <directory>src/test/resources</directory> 
      <filtering>true</filtering> 
     </testResource> 
    </testResources> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.18.1</version> 
      <configuration> 
       <suiteXmlFiles> 
        <suiteXmlFile>src/test/resources/TestNG.xml</suiteXmlFile> 
       </suiteXmlFiles> 
      </configuration> 
     </plugin> 
    </plugins> 
</build>