We have a group of tests that can be run in parallel and a group of tests that can only be run sequentially.
I would like TestNG to execute all of them in one run but schedule sequential tests sequentially, and parallel tests in parallel. How I can achieve that with TestNG?
I considered the following:
Define two test groups with
@Test(group='parallel-tests')
and@Test(group='sequential-tests')
annotations and run each group separately with proper configuration. I don't like it because I wanted to execute both groups in one run.Create testng.xml file with two suites:
<suite name="Suite1" verbose="1" > <test name="ParallelGroup" parallel="classes" > <classes> <class name="testngtests.TestParallel"/> </classes> </test> <test name="Sequential" parallel="false" > <classes> <class name="testngtests.copy.TestSeq"></class> </classes> </test> </suite>
but then I will need to explcitly list classes or packages of tests to include.
A solution would be to combine both approaches, i.e., something like
<suite name="Suite1" verbose="1" >
<test name="ParallelGroup" parallel="classes" >
<test-group ref="parallel-tests" />
</test>
<test name="Sequential" parallel="false" >
<test-group ref="sequential-tests" />
</test>
</suite>
but I see no way to reference to test groups in testng.xml, there's nothing like test-group ref
in TestNG.