My TestSuite is running during the build using ant target.
I would like, in my suite, to access the TestResult and do some actions if the tests succeed or not.
Is there a way to retrieve the object in the tear down method?
Thanks
With jUnit3 I'd try subclassing Test
and overwrite the run
method. That would provide me with access to the TestResult
instance. Something like this:
public class MyTest extends Test {
@Overwrite
public void run(TestResult result) {
super.run(result);
doSomethingWithResults(result);
}
// ...
}
With jUnit4 I'd look into implementing a TestRunner (based on the standard runner). It sounds difficult but actually isn't. Subclass the default one and simply add the @RunWith
annotation to use your own runner (that can do something with the results)