I have some unit-tests which are setup by an @Before-method and cleaned by an @After-method. Now I want to do the @After-method something different if the test succeed than if it failed. How can I do this?
Asked
Active
Viewed 897 times
1 Answers
-1
You need to use a boolean flag in your @After method to decide what you want to do in case of success or failure. You can simply define a flag isPassed
in your test class, turn it true if test case passed or turn it false in case of failure. Simply read this variable in your @After method and decide about what you need to do.

Juned Ahsan
- 67,789
- 12
- 98
- 136
-
I think I'm searching for the one position where to add that isPassed = true, so I don't have to set it in every test – mibutec Aug 28 '13 at 12:10