Ok, so referring to TestNG doc I can run tests either sequentially (by default in a test suite) or in parallel using <suite parallel="tests">.
Now here is my TestNG config
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Complete test suite">
    <listeners>
        <listener class-name="com.uas.test.portlet.integration.util.WebDriverListener" />
        <listener class-name="org.uncommons.reportng.HTMLReporter" />
    </listeners>
    <test name="Parallel tests" parallel="methods" thread-count="4">
        <groups>
            <run>
              <exclude name="sequential-test"></exclude>
            </run>
        </groups>
        <packages>
            <package name="com.uas.test.portlet.integration.main" />
            <package name="com.uas.test.portlet.integration.main.categorymanager" />
            <package name="com.uas.test.portlet.integration.main.admin" />
        </packages>
    </test>
    <test name="Sequential tests" parallel="false" >
        <groups>
            <run>
                <include name="sequential-test"></include>
            </run>
        </groups>
        <packages>
            <package name="com.uas.test.portlet.integration.main" />
            <package name="com.uas.test.portlet.integration.main.categorymanager" />
            <package name="com.uas.test.portlet.integration.main.admin" />
        </packages>
    </test>
</suite>
As you can see, I have 2 types of tests : tests which can be run in parallel and others that should be run in sequential. No parallel=tests attribute in my suite so <test> tags are run sequentially, in such a manner that my first parallel test group is run first and then the sequential ones.
That is perfect, but I would like to go a bit further than this and have 2 subgroups of my sequential tests, each of which could be run in parallel with each other, but both after the main parallel tests... unfortunately I haven't been able to do that... So to summarize what I want :
1. RUN Parallel tests main group 
THEN
2. RUN Sequential tests main group
   --> Sequential subgroup A RUNS IN PARALLEL with Sequential subgroup B (test 1 from subgroup A could run in parallel with test 3 from subgroup B, they are independant)
   --> Each test within subgroup A should run sequentially
   --> Each test within subgroup B should run sequentially
Any idea on how to do that with TestNG config file ? (I would like to avoid using Ant or such).
Two separate suites may help. They will be executed sequentially. Just put your tests inside of them depending on what you need.
 <suite-files>
   <suite-file path="./suite1.xml" />
   <suite-file path="./suite2.xml" />
  </suite-files>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With