PowerMockito的性能影响

Bas*_*stl 5 junit spring powermock

我们有以下模式,它对测试执行时间产生了巨大影响.

我想了解原因.

@RunWith(PowerMockRunner.class)
@PrepareForTest(SomeSingleton.class)
public class SomeTest {

@Before
public void setUp() throws Exception {
    PowerMockito.mockStatic(SomeSingleton.class);
    Mockito.when(SomeSingleton.getInstance()).thenReturn(new SomeSingleton());
}
Run Code Online (Sandbox Code Playgroud)

SomeSingleton类是非常遗留的,并且(没有玩笑)从spring容器中获取它的共享实例.

备注:我为实例添加了一个公共静态setter(破坏了单例的想法),但为此赢了25秒!

问题:"PrepareForTest"和"mockStatic"到底需要25秒才能做到这一点?