I am trying to verify that a static method is not called in a certain configuration, in a unit test.
I am thus using PowerMock (powermock-core:2.0.4
& powermock-module-junit4:2.0.4
) and its Mockito API (powermock-api-mockito2:2.0.4
).
When doing
PowerMockito.mockStatic(MyClass.class);
serviceUnderTest.methodThatShouldNotCallStaticMethod(arg1, arg2); //service not of type MyClass of course
PowerMockito.verifyStatic(MyClass.class, never());
MyClass.staticMethod(any(), any());
on a test method within a class annotated with
@RunWith(PowerMockRunner.class)
@PrepareForTest({MyClass.class})
I get the following error : org.mockito.exceptions.misusing.NotAMockException:
Argument passed to verify() is of type Class and is not a mock!
.
What did I do wrong and how to solve it ?
Thanks