1
votes

I'm new to Automation and wondering how do I execute 2 test classes in a specific order if they belong to different tests.

I have the following testng.xml file:

<suite name="myTestProject" parallel="false">
    <listeners>
        <listener class-name="utility.eTestListener"></listener>
    </listeners>
    <test name="LOGINTEST">
        <parameter name="browserName" value="chrome"/>
        <parameter name="url" value="https://url/"/>        
        <groups>
            <define name = "all">
                <exclude name="negativeTest"/>
                <include name="loginTest"/>             
            </define>

            <run>
                <include name = "all"/>
            </run>  
        </groups>   
        <classes>
            <class name="site.tests.suite.TestClass1"/>
        </classes>
    </test>
    <test name="FILE_RECON">
        <groups>
            <define name = "all">
                <include name="IncomingVisa"/>
            </define>
            <run>
                <include name="All"/>
            </run>
        </groups>   
        <classes>
            <class name="site.tests.suite.TestClass2"/>
        </classes>
    </test> 
</suite>

When executing the project, TestClass2 is executed first. How can I change the testng.xml or perform some other changes in order for the TestClass1 run first and TestClass2 run second?

1

1 Answers

1
votes

Within TestNG <test> is the smallest unit of execution. You cannot span across <test> tags and visualize an execution.

So this is currently NOT supported in TestNG and I am pretty sure that its not likely to be supported as well.

If you would like to control the order of the test classes, then you would need to include them within the same <test> tag only.