1
votes

I use @Parameters("DeviceModel") in my Tests I run parallel 3 threads via testNG.xml file. In TestNG.XML I pass 3 parameters.

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

When testNG.xml is executing it takes 1-st param for thread1, 2-nd param for thread 2, and 3-rd for thread 3. Thus i get 3 parallel threads with different params each.

Now i wish to do a parallel test via Maven SureFire plugin with TestNG. I pass following values in 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>

This does not work. My Test executs only the third parameter for each thread. How i can pass 3 different parameters to TestNg for 3 parallel threads with maven?

2

2 Answers

0
votes

You might want to try passing all parameters in one <DeviceModel>tag and parse it inside @DataProvider or @Factory See documentation for details enter link description here

0
votes

It is possible to continue using the TestNG.xml also with Maven.

In this example the suite file TestNG.xml is located in src/test/resources subfolder:

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