TestNG @Test attributes – threadPoolSize, invocationCount, timeOut

Let’s see invocationCount implementation


OutPut:
Thread ID: 1
Thread ID: 1
Thread ID: 1
Thread ID: 1
Thread ID: 1
above method ran 5 times, a single thread will be assigned to run the method one by one..

Now let’s see with threadPoolSize implementation


OutPut:
[ThreadUtil] Starting executor timeOut:0ms workers:5 threadPoolSize:3
Thread ID: 11
Thread ID: 12
Thread ID: 13
Thread ID: 12
Thread ID: 11
Above method ran 5 times, but 3 threads shared the 5 times of test run…(threads 11, 12 and 13)

Now let’s see threadPoolSize with timeOut implementation


OutPut:
[ThreadUtil] Starting executor timeOut:2000ms workers:5 threadPoolSize:3
Thread ID: 11
Thread ID: 12
Thread ID: 13
Above method ran only 3 times, as the timeOut is set to 2sec (a particular thread only holds for 2sec), and testcase takes 1.5sec (by knowing we kept 1.5sec delay), and ran the tests no of times with in the 2sec, so each thread only ran once…

Content posted is based on learning or working experience, Share the post with others if find useful, Any queries?, leave comments or discuss on our facebook:qavalidation.com, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: