Testng annotations

108 views
Skip to first unread message

Mosam Mehta

unread,
Aug 6, 2015, 10:24:51 AM8/6/15
to testng-users
Is it possible to execute any method after @Aftersuite methoda are completed?
I have one code in which i need to execute one method after completion of all methods in @AfterSuite annotation.

Shawn McCarthy

unread,
Aug 6, 2015, 10:34:50 AM8/6/15
to testng-users
There is an ISuiteListener that has onStart (which executes before @BeforeSuite) and onFinish (which executes after @AfterSuite).

http://testng.org/javadocs/org/testng/ISuiteListener.html

Mosam Mehta

unread,
Aug 13, 2015, 5:58:19 AM8/13/15
to testng-users
Hi,

Thanks for your reply. But this solution didn't work. The method which is called at the end of @AfterSuite got called even after the onFinish method.
Is there any other solution?

Thanks.

Krishnan Mahadevan

unread,
Aug 19, 2015, 4:47:05 AM8/19/15
to testng...@googlegroups.com
Mosam,

You have two options for this.

1. You can plug in your custom code that needs to be executed after onFinishSuite() by plugging it inside a IReporter implementation [ http://testng.org/javadocs/org/testng/IReporter.html ] This gets called after all activities related to a Suite are completed.
2. You plug-in your logic as part of a ShutdownHook [http://hellotojavaworld.blogspot.in/2010/11/runtimeaddshutdownhook.html]. That way your code would be the last thing to get executed before the JVM exits.



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 Scribbings @ http://rationaleemotions.wordpress.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 post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages