Re: error if I pass "ITestResult" to @AfterClass

593 views
Skip to first unread message

Petter Isberg

unread,
May 26, 2013, 4:23:11 AM5/26/13
to testng...@googlegroups.com
Hi!

According to the TestNG documentation about native dependency injection (http://testng.org/doc/documentation-main.html#native-dependency-injection) only @AfterMethod takes the ITestResult parameter. This seems to be because the ITestResult contains information about the executed test method. When you try to get the isSucess result in @AfterClass there is no telling from which test method you want the result. The documentation however states that an @AfterClass method can take a XMLTest parameter, unless you want to have an instance variable in your class letting you know of the result (can be set in @AfterMethod for example), I guess you can get the desired information out of the XMLTest object.

I guess you have to try it. Let us know if it works :)

Regards
Petter

Suba Narayanan

unread,
Feb 9, 2017, 9:13:21 AM2/9/17
to testng-users
Hi,

 I've added ITestResult parameter to the @AfterMethod,and driver.quit() to @AfterClass. No Error and the screenshot was taken in case of failure.

Thanks,
Suba

⇜Krishnan Mahadevan⇝

unread,
Feb 9, 2017, 9:33:58 AM2/9/17
to testng...@googlegroups.com
Suba,

Since you revived a nearly 3 year old thread, and since you haven't added much of context in terms of what information you are trying to add to this thread, may I request you to please add some sample source code which would show what you have done ?
That way in the future, if anyone stumbles into this thread they would get some better context in terms of how this was solved.


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+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://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