I am trying to using $clinit of the Mockup class on a class that has static initialisers. eg.
new Mockup<ClassWithStaticInitialisers>() {
@Mock
public void $clinit() {
System.out.println("Custom CLINIT!");
}
};
ClassWithStaticInitialisers.doSomething();
What appears to be happening however is that something has already loaded the ClassWithStaticInitialisers class prior to the mockup being declared, therefore the default static initialisers are called instead of the mockup version.
I have tried the following with no success, something is still loading the class prior to @BeforeClass as the default static initialisers are called (or at least it seems that way)
@BeforeClass
public static void setup() {
new Mockup<ClassWithStaticInitialisers>() {
@Mock
public void $clinit() {
System.out.println("Custom CLINIT!");
}
};
}
@Test
public void testMyTest() {
ClassWithStaticInitialisers.doSomething();
}
Is there anyway I can get JMockit to reload it's implementation of the ClassWithStaticInitalisers?
Aucun commentaire:
Enregistrer un commentaire