Strategy to access retry analyzer within an annotation transformer

88 views
Skip to first unread message

Bryan Davis

unread,
Jul 14, 2021, 5:09:24 AM7/14/21
to testng-users
In TestNG >=7.4.0 the retry analyzer is no longer accessible via the ITestAnnotation.  For example, the following code no longer works ("getRetryAnalyzer" method has been removed):

RetryAnalyzer retryAnalyzer = (RetryAnalyzer)annotation.getRetryAnalyzer();
retryAnalyzer.setMaxCount(5);

Is there a new strategy that can be used in order to access it within the transform method of the IAnnotationTransformer interface?  I am currently modifying the retry count based on groups within the @Test annotation.

Thank you.

⇜Krishnan Mahadevan⇝

unread,
Aug 9, 2021, 12:00:00 AM8/9/21
to testng-users
The instance of the retry analyzer is no longer available for manipulation. 
That said and done, I think you can still access the "@Test" annotation's group attributes from within your Retry analyzer and then dynamically decide what should be the retry count that is to be used till a pass/fail can be determined.

You could also try setting the value via an attribute in ITestResult through a beforeInvocation and have that read from within your retry() method.


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/410732b6-940b-4856-b3ca-0dd6906373f9n%40googlegroups.com.

Bryan Davis

unread,
Aug 30, 2021, 6:50:08 PM8/30/21
to testng-users
Using your first suggestion I am now accessing the group attributes from within the retry analyzer and was successful in removing the need to manipulate the retry analyzer from the annotation transformer.
Thank you Krishnan!

Reply all
Reply to author
Forward
0 new messages