'How to execute two suite files(which contains class files) in Parallel in Selenium Java Maven Framework

In my organization as per existing framework. The suite are getting created in xml file with class files and these xml files are called in testng.xml. I have provided the content below.

The current execution pattern is, Suite1.xml will trigger first and it will execute TestScript1,TestScript2,TestScript3(class files) in sequential order. Then it will initiate Suite2.xml and it will execute TestScript11,TestScript12,TestScript13(class files) in sequential order.

PROBLEM: I would like to have a mechanism in such a way, Scripts/Class files mentioned in Suite1.xml should go sequentially. But at the same time in parallel, Suite2.xml related Scripts/Class files should get executed sequentially.

So suites should execute parallel, but scripts/classes in the suite should execute sequentially.

REQUEST: Can someone please suggest a solution or what modification to be done to them xml to achieve this.

Testng.xml looks as below:

  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <suite name="MyFramework">
    <suite-files>
        <suite-file path="SUITE1.xml"/>
        <suite-file path="SUITE2.xml"/>
    </suite-files>
</suite>

SUITE1.xml as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<suite configfailurepolicy="continue" name="SUITE1" preserve-order="true">
    <test name="TestScript1">
        <classes>
            <class name="com.scripts.customer.module.TestScript1"/>
        </classes>
    </test>
    <test name="TestScript2">
        <classes>
            <class name="com.scripts.customer.module.TestScript2"/>
        </classes>
    </test>
    <test name="TestScript3">
        <classes>
            <class name="com.scripts.customer.module.TestScript3"/>
        </classes>
    </test>
</suite>

SUITE2.xml is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<suite configfailurepolicy="continue" name="SUITE1" preserve-order="true">
    <test name="TestScript11">
        <classes>
            <class name="com.scripts.customer.module.TestScript11"/>
        </classes>
    </test>
    <test name="TestScript12">
        <classes>
            <class name="com.scripts.customer.module.TestScript12"/>
        </classes>
    </test>
    <test name="TestScript13">
        <classes>
            <class name="com.scripts.customer.module.TestScript13"/>
        </classes>
    </test>
</suite>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source