My motto for Java is \"just because Java has static blocks, it doesn\'t mean that you should be using them.\" Jokes aside, there are a lot of tricks in Java that make testing a
Not really an answer, but just wondering - isn't there any way to "reverse" the call to Mockit.redefineMethods
?
If no such explicit method exists, shouldn't executing it again in the following fashion do the trick?
Mockit.redefineMethods(ClassWithStaticInit.class, ClassWithStaticInit.class);
If such a method exists, you could execute it in the class' @AfterClass
method, and test ClassWithStaticInitTest
with the "original" static initializer block, as if nothing has changed, from the same JVM.
This is just a hunch though, so I may be missing something.