suite file with parallel tests - exclude specific methods from running in parallel

111 views
Skip to first unread message

shay frid

unread,
Jun 1, 2023, 4:01:56 AM6/1/23
to testng-users
Hi, 

I have the following suite file (example)
<suite name="suiteFile" parallel="tests" thread-count="2">
<test name="Test1">
   <classes>
      <class name="TestClass1"/>
</classes>
</test>
<test name="Test2">
   <classes>
      <class name="TestClass2"/>
</classes>
</test>
</suite>

Is it possible to exclude specific methods in TestClass1 for example from running in parallel? when TestClass1.method_1 will run, no other methods will run in parallel, not even methods in TestClass2

Thanks,
Shay

⇜Krishnan Mahadevan⇝

unread,
Jun 2, 2023, 12:24:35 AM6/2/23
to testng...@googlegroups.com
I don't think that this capability exists as of today. Maybe you can help log a bug and we can see what we can do about it?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/ab960477-fc76-4ae4-acd5-402cadc94167n%40googlegroups.com.

shay frid

unread,
Jun 8, 2023, 5:00:02 AM6/8/23
to testng-users
Is it possible a test will lock other threads until it finishes?
for example:
<suite name="suiteFile" parallel="tests" thread-count="1">
<test name="Test1" parallel="methods" thread-count="4">

   <classes>
      <class name="TestClass1"/>
</classes>
</test>
<test name="Test2">
   <classes>
      <class name="TestClass2"/>
</classes>
</test>
</suite>



⇜Krishnan Mahadevan⇝

unread,
Jun 8, 2023, 5:02:29 AM6/8/23
to testng...@googlegroups.com
Its not clear what you are asking for. The suite xml illustration also doesnt help a lot. Can you please elaborate?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

Sagar Attarde

unread,
Jun 8, 2023, 5:08:23 AM6/8/23
to testng...@googlegroups.com
You changes the code and write to methodname(Unable=false)

shay frid

unread,
Jun 8, 2023, 7:25:08 AM6/8/23
to testng-users
Assume we have 20 tests in a class. I defined this class will run with 4 threads in parallel. 
<test name="Test1" parallel="methods" thread-count="4">
However, 2 of the tests must run alone (due to a change in configuration). 
Can I isolate these 2 tests? (using mutex if supported)


⇜Krishnan Mahadevan⇝

unread,
Jun 8, 2023, 7:51:36 AM6/8/23
to testng...@googlegroups.com
You would need to build the logic at your end. TestNG does not provide you out of the box implementations for such ask.

You can start off by defining a base class which implements an IHookable listener. All your test classes would extend this base class.
Within your base class'es IHookable's implementation, you define whatever isolation logic you need.

All that TestNG does when you say run tests in parallel is :
  • Defines a thread pool executor with a size that matches the thread count as specified in your suite file.
  • Builds a directed acyclic graph which would ensure that independent tests run first followed by dependent tests
  • Runs through this graph coupled with the executorservice.




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

Grigoriy Frank

unread,
Jun 8, 2023, 8:33:24 AM6/8/23
to testng...@googlegroups.com
Hi. Try to organize your tests like this:

demo.jpg

чт, 8 июн. 2023 г. в 19:51, ⇜Krishnan Mahadevan⇝ <krishnan.ma...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages