Is there any way I can get the test result in the teardown (@After) method? I\'d like to do clean up after the tests depending on the result.
Could not
Why not set the result of a test in a class member and then act on it in the @After method?
public enum TestResult {
...
}
public class TestClass {
private TestResult result;
...
@Test
public void aTest() {
// set up test
// call class under test
// assert something and set result based upon outcome
this.result = ...;
}
...
@After
public void teardown() {
// clean up based upon this.result
}
}
I suspect you would not have too many different results and a finite set will suffice.