Parallel test blocks, except one

105 views
Skip to first unread message

Aditya Das

unread,
Nov 5, 2020, 7:22:06 AM11/5/20
to testng-users
Hi,

Can anyone suggest me a solution where I can have parallel = 'tests' on a suite level on all test blocks barring one.
What I mean is I will have 5 test blocks in TestNG, out of which 4 can be executed in parallel, but the last one can only run in single thread i.e. without any other parallel execution going on whilst the last one is running.
P.S. Creating a different suite for the last test block is not feasible in my project

for reference:-

<suite name="automationTest" verbose="1" parallel="tests" thread-count="4">
    <test name = 'test1'></test>
    <test name = 'test2'></test>
    <test name = 'test3'></test>
    <test name = 'test4'></test>
    <test name = 'singleThreadedTest'></test>
</suite>

⇜Krishnan Mahadevan⇝

unread,
Nov 5, 2020, 7:31:59 AM11/5/20
to testng-users
The straight forward option is to segregate the odd test into its own suite.
If that's not an option, then there's not much that can be done. We have hit a dead end!

The other round about way would be to add an IAlterSuiteListener, as a listener to this suite, which internally looks for a name pattern to figure out which is a single threaded suite, and then isolates it into a separate XmlSuite object and then wires it in. But then again, that's literally equivalent to you creating a separate suite (Not to mention, involves no coding as well)

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

http://rationaleemotions.com/

Sent from BlueMail

Aliasger Kiranawala

unread,
Nov 5, 2020, 8:07:24 AM11/5/20
to testng-users
I did similar to what Krishnan suggested. Moreover I kept single suite and divided test into class levels

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="test suite">

     <test name="tests" parallel="methods" thread-count="10">

        <classes>

              <class name="Test-1" />

              <class name="Test-2" />

     </classes>

</test>

<test name="tests" parallel="methods" thread-count="4">

    <classes>

           <class name="Test-different-threads" />

     </classes>

</test>

</suite>

Aditya Das

unread,
Nov 6, 2020, 8:25:46 AM11/6/20
to testng-users
Thanks a lot, I tried your IAlterSuiteListener way, even though it is a bit complicated and doing the same thing as creating another physical suite, it suits my project constraints.

On Thursday, November 5, 2020 at 6:01:59 PM UTC+5:30 Krishnan Mahadevan wrote:
Reply all
Reply to author
Forward
0 new messages