'PowerMockito.verifyStatic method does not work
I am trying to use PowerMockito in order to test a static method in my service. I have the following test method:
@PrepareForTest(LoggingUtils.class)
@RunWith(PowerMockRunner.class)
public class SiteServiceImplTest {
@Test
public void test() {
// code omitted
PowerMockito.mockStatic(LoggingUtils.class);
Page<SiteDTO> result = siteService.findAll(request, sort);
PowerMockito.verifyStatic(LoggingUtils.class, Mockito.times(1));
}
}
But when I run this test, it throws the following error:
org.mockito.exceptions.misusing.NotAMockException: Argument passed to verify() is of type Class and is not a mock! Make sure you place the parenthesis correctly! See the examples of correct verifications:
verify(mock).someMethod();
verify(mock, times(10)).someMethod();
verify(mock, atLeastOnce()).someMethod();
So, how can I use PowerMockito and test my static method?
The static method is as following:
LoggingUtils.info("The ...);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
