'TestNG: Running multiple suites with preserved order using <suite-files> tag

I am trying to run multiple suites from one overall suite file. I define the suites I need to run and run the "master" suite file. I have used preserve-order to run each suite in sequence, however the behaviour is not as I would expect. It seems that it runs them straight away, one after the other, almost in parallel.

Does anyone know a way I can execute the suites, preserving the order, ideally waiting for first suite to finish before second suite will run?

My suite setup is as follows:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="My test suite" preserver-order=true>
    <suite-files>
        <suite-file path="Test1.xml"></suite-file>
        <suite-file path="Test2.xml"></suite-file>
        <suite-file path="Test3.xml"></suite-file>
    </suite-files>
</suite>

Regards, Jacko



Solution 1:[1]

Is the issue that you haven't specified the attribute correctly? It should be

preserve-order="true"

not

preserver-order=true

Solution 2:[2]

The best option is to remove suite-file tag (because it is not affected by preserve-order option by design) and refactor testng.xml to use test tags and dependencies on groups or preserver-order.

Solution 3:[3]

According to the testng documentation,

By default, TestNG will run your tests in the order they are found in the XML file. If you want the classes and methods listed in this file to be run in an unpredictible order, set the preserve-order attribute to false

Moreover, if you want the execution to run in an unpredictable manner you can do it as following.

<suite name="My test suite" preserver-order="false">
    <suite-files>
        <suite-file path="Test1.xml"></suite-file>
        <suite-file path="Test2.xml"></suite-file>
        <suite-file path="Test3.xml"></suite-file>
    </suite-files>
</suite>

You have to specify the

preserve-order = "false"

not

preserve-order = false

Solution 4:[4]

In Suite tag, specify attribute thread-count=1, parallel="false". Let me know if this works.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 VolleyJosh
Solution 2 RocketRaccoon
Solution 3 Erangad
Solution 4 Mrunal Gosar