I would like to do some "own stuff" when an assertion in JUnit fails. I would like to have this:
public class MyAssert extends org.junit.Assert {
// @Override
static public void fail(String message) {
System.err.println("I am intercepting here!");
org.junit.Assert.fail(message);
}
}
Of course, this does not work, because you cannot override static methods. But if it would, this would be nice, because every assert function like assertTrue()
calls the fail()
method. Thus, I could easily intercept every assertion.
Does there exist any way to do what I want to do here, without implementing all different flavors of assert...
?