Search code examples
maventestngmaven-failsafe-plugin

Execute test suites in a specific order


I'm using the maven-failsafe plugin to trigger testng suites with configuration similar to

<suiteXmlFiles>
 <file>src/test/resources/suites/somesuite.xml</file>
 <file>src/test/resources/suites/anothersuite.xml</file>
 <file>src/test/resources/suites/yetanothersuite.xml</file>
</suiteXmlFiles>

but the suites or the tests within them are not getting executed in the correct order. Is there a way to specifiy that the suites should be executed in the below order

  1. somesuite.xml
  2. anothersuite.xml
  3. yet another suite.xml

I don't care about the order in which the tests within a suite is executed, but would like to execute one suite only after the previous one has completed. Is there some configuration which I could use to achieve the same?


Solution

  • Create a seperate testng.xml file and add something like below:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="Suite">
        <suite-files>
            <suite-file
                path="path-to\suite1.xml" />
            <suite-file
                path="path-to\suite2.xml" />
        </suite-files>
    </suite>
    

    And then add this testng.xml file to your maven suite