parallel testing in TestNG

104 views
Skip to first unread message

walaa jumah

unread,
Sep 18, 2023, 4:46:50 AM9/18/23
to testng-users
Hello, 
I'm working on optimizing the execution time of my tests by utilizing parallel testing with a TestNG XML file.
 I've attempted to implement parallel execution with the following configurations:
<suite name="Suite Login Test" verbose="1" parallel="tests">

<test name="test" parallel="classes" thread-count="2">
<test name="test" parallel="methods" thread-count="2">
<test name="test" parallel="classes" thread-count="2">

 However, I've noticed that the execution time doesn't decrease significantly, and sometimes it even becomes greater than when not using parallel execution. 
I'm looking for suggestions on how to effectively configure parallel execution to reduce the overall execution time for my project.
Any advice or best practices would be greatly appreciated.
 Thank you.

Krishnan Mahadevan

unread,
Sep 18, 2023, 5:10:29 AM9/18/23
to testng...@googlegroups.com
What do your tests do? 

Lets start with that. Are they UI based tests or just API based?

If they are UI based then where are the browsers being spun off ? Are they being run in 

Docker containers (or)
Locally installed browsers (or)
Do you use a selenium grid?

Have you looked at the environment where your tests are running to see if the resource utilisation ( cpu/memory ) spikes when concurrency increases?

There are a lot of things that can stall/degrade execution. 

Feel free to add more contexts around each of these areas. 

Thanks & Regards
Krishnan Mahadevan

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

From: testng...@googlegroups.com <testng...@googlegroups.com> on behalf of walaa jumah <jumah...@gmail.com>
Sent: Monday, September 18, 2023 1:45:06 PM
To: testng-users <testng...@googlegroups.com>
Subject: [testng-users] parallel testing in TestNG
 
--
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/aee3007b-4337-4822-975f-502a9ecb80d7n%40googlegroups.com.

testng-users

unread,
Sep 19, 2023, 7:24:53 AM9/19/23
to testng-users

Thank you for reaching out.
 My tests primarily focus on testing an e-commerce website and it's UI based.
I'm using Selenium WebDriver to define and control the browser locally through Selenium Manager.
is there any suggestion to run the test in parallel & reduce the time?

⇜Krishnan Mahadevan⇝

unread,
Sep 19, 2023, 9:58:48 AM9/19/23
to testng...@googlegroups.com
There's still not much context that you have shared.

We don't have visibility into what the bottlenecks are when you run your test.

So I would suggest that you start exploring the below areas:

  • Are there one or more synchronized blocks in your execution path? If yes, then it could be one of the bottle necks since critical paths are always sequentially executed by multiple threads.
  • You mentioned that you are running UI tests and that they are spawning browsers locally. Depending on the machine on which you are running your tests, you will see degraded performance once you start spawning too many browser instances on one machine. You might want to check if that's the case and then move over to using a docker based execution environment approach or use a selenium grid.
  • Also what does the resource utilisation of your test environment look like when you run more tests in parallel and see a degradation in performance? It could be a resource constraints limitation that you are hitting when you start sending too many concurrent requests at your test environment. Usually test environment infra is a very basic infra that people run to optimise costs.


Thanks & Regards
Krishnan Mahadevan

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

Reply all
Reply to author
Forward
0 new messages