SuppressStaticInitializationFor
package com.example;
public class ClassWithStaticInitializer {
private static Handler mHandler = new Handler();
}@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor({
"com.example.ClassWithStaticInitializer"
})
public class ClassWithStaticInitializerTest {
// now when we call
@Before
public void setup throws Exception {
// At this stage, ClassWithStaticInitializer.mHandler will be null
Whitebox.setInternalState(ClassWithStaticInitializer.class, "mHandler", mckHandler);
}
}Last updated