How to get the current test number while using invocation / pool thread/ parallel

31 views
Skip to first unread message

Eyal

unread,
Aug 24, 2021, 4:31:55 AM8/24/21
to testng-users
Hello,

While using pool thread or invocation mode I need to know that x number of tests are done so I can change some data variables.

what is the best way to have it generically ?
to store the test number like 1
2
3
4
and so on....
and then use it for my conditions ?

Thanks!

Baubak

unread,
Aug 24, 2021, 4:51:53 AM8/24/21
to testng-users
You can do this in the listeners (not limited to):
I, personally, would have a static variable that is iincremented.

Best regards,

Baubak

⇜Krishnan Mahadevan⇝

unread,
Aug 24, 2021, 6:46:57 AM8/24/21
to testng-users
What exactly are you trying to solve ?

If its merely a matter of keeping a running counter of how many tests have so far been executed, then you can very well use the suggestion that Baubak has shared. 

But if you are trying to figure out how many "x" tests have been completed in a total of "y" tests, then it would be a tricky question, because that is something that even TestNG doesnt know because a test method could be powered by an invocation count or it could be backed by a data provider etc.,

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/55eb90c1-8f7b-426c-8921-3bacde2f3cb2n%40googlegroups.com.

Eyal

unread,
Aug 24, 2021, 7:21:35 AM8/24/21
to testng-users
That is exactly what I need!
Since I also have load testing, rest api load tests (rest assured)
then I need to tell my code that if x tests are done then take new data (Random data to create new json rendered)

So if I can know that 3 tests are done (invocation/parallel/multithread)
then I can try to build some data generator only in case that thread number is bigger then x.

that is too complicated.

ב-יום שלישי, 24 באוגוסט 2021 בשעה 13:46:57 UTC+3, Krishnan Mahadevan כתב/ה:
Reply all
Reply to author
Forward
0 new messages