【发布时间】:2021-04-05 06:24:04
【问题描述】:
我想模拟静态方法,因此使用依赖“mockito-inline”3.8 版本而不是“mockito-core”
静态方法模拟工作正常,但我模拟接口的旧测试失败并出现以下错误
org.mockito.exceptions.misusing.NotAMockException:
Argument passed to when() is not a mock!
Example of correct stubbing:
doThrow(new RuntimeException()).when(mock).someMethod();
恢复使用 mockito-core 解决了这个问题,但我无法模拟静态方法
有什么方法可以为每个类选择不同的模拟引擎(子类/内联)?
【问题讨论】:
标签: unit-testing mockito