【发布时间】:2020-10-08 20:25:18
【问题描述】:
我需要模拟一个静态方法。我知道有两个工具可以帮助做到这一点:PowerMockito 和 JMockit,它们都需要使用 @RunWith 注释。但是,我已经为 SpringRunner 使用了 @RunWith 来设置一些 @Autowired 依赖项,以及 it seems you can't use @RunWith twice。
I see that PowerMockito has a PowerMockRunnerDelegate,看起来很有希望。但由于种种原因,我现在一直坚持使用 JMockit。是否有与之对应的 JMockit?
我基本上需要模拟一个静态方法并同时为我的测试设置@Autowired 依赖项。
【问题讨论】:
-
JMockit 从来不需要使用
@RunWith。不久前它支持,但现在不再支持了。
标签: spring-boot junit junit4 jmockit