javaseleniummaventestngparallel-testing

Selenium Parallel testing with Maven and TestNG


I am trying to run my tests in parallel with Maven by using 2 xml files but it doesn't seem to work. I have tried the steps/parameters from the Maven documentation: http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html

Below is my pom.xml file:

                    <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>feature1.xml</suiteXmlFile>
                            <suiteXmlFile>feature2.xml</suiteXmlFile>-->
                        </suiteXmlFiles>

and this is the feature1.xml file:

<suite name="tests">
    <test name="feature1" group-by-instances="true">
        <parameter name="browser" value="chrome"/>
        <classes>
            <class name="testclass"/>
        </classes>
    </test>
</suite>

What parameters/changes I should make in order for this to work?

Thank you


Solution

  • I am posting the solution that I found and it worked after all:

    I have added this in the configuration node:

    <properties>
    <property>
    <name>suitethreadpoolsize</name>
    <value>2</value>
    </property>
    </properties>    
    

    Also the issue was that I was using a static WebDriver (Singleton class), the reason why the tests didn't run in sequence. I have made the method WebDriver public and instantiate it in every test class runner. Now the tests are running in parallel successfully.