Jacko Moore
Jacko Moore

Reputation: 51

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

Upvotes: 5

Views: 8245

Answers (4)

Erangad
Erangad

Reputation: 861

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

Upvotes: 0

RocketRaccoon
RocketRaccoon

Reputation: 2599

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.

Upvotes: 0

VolleyJosh
VolleyJosh

Reputation: 161

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

preserve-order="true"

not

preserver-order=true

Upvotes: 0

Mrunal Gosar
Mrunal Gosar

Reputation: 4683

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

Upvotes: -1

Related Questions