I want to do some “own things” when the statement in JUnit fails. I would like to have this:
public class MyAssert extends org.junit.Assert {
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 that were the case, that would be good, because every assert function like assertTrue()that calls the method fail(). That way, I could easily intercept every statement.
Is there any way to do what I want to do here without doing all the different options assert...?
source
share