我正在尝试验证在单元测试中,在某些配置中未调用静态方法。
因此,我正在使用PowerMock(powermock-core:2.0.4
&powermock-module-junit4:2.0.4
)及其Mockito API(powermock-api-mockito2:2.0.4
)。
执行时
PowerMockito.mockStatic(MyClass.class);
serviceUnderTest.methodThatShouldNotCallStaticMethod(arg1, arg2); //service not of type MyClass of course
PowerMockito.verifyStatic(MyClass.class, never());
MyClass.staticMethod(any(), any());
在带有]的类中的测试方法上>
@RunWith(PowerMockRunner.class) @PrepareForTest({MyClass.class})
我收到以下错误:
org.mockito.exceptions.misusing.NotAMockException: Argument passed to verify() is of type Class and is not a mock!
。
我做错了什么以及如何解决?
谢谢
我正在尝试验证在单元测试中,在某些配置中未调用静态方法。因此,我正在使用PowerMock(powermock-core:2.0.4&powermock-module-junit4:2.0.4)及其...
原来是a Powermock bug ...