Make tearDown() aware of exceptions.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, January 16, 2006 02:58 PM

Hi there,



What I would like to do is to be able to somehow tell whether the tearDown() function has been called after an Exception has been thrown. In essence, I have some cleanup code that needs to be run _only_ when a test case fails and this must be done for all tests.



For instance, if a test succeeded, this cleanup script would not be called. However, if an exception has been thrown I need to call this cleanup script.



Thank you,

Re: Make tearDown() aware of exceptions.

Posted By:   ankush_purwar  
Posted On:   Tuesday, January 17, 2006 02:38 PM

I have done work on JUnit 2 yrs ago.
I hope before execute every test Case setUp() will called and after completion of test case tearDown() will call.
If your test case throws the exception, then you can set a flag that tells you that exception is thrown.
And check this flag in tearDown().

Hope it will solve your problem.
About | Sitemap | Contact