verifyStatic get NotAMockExcption from mockito

463 views
Skip to first unread message

Wade Hong

unread,
May 30, 2019, 10:58:49 AM5/30/19
to PowerMock
Hey guys,

I'm trying to migrate PowerMock from 1.7.4 to 2.0.2 and Mockito from 1.10.19 to 2.25.0.
But the test using PowerMockito.verifyStatic now all get message like :

org.mockito.exceptions.misusing.NotAMockException: 
Argument passed to verify() is of type Class and is not a mock!

our test logic is quite the same as the example at https://github.com/powermock/powermock/wiki/Mockito#mocking-static-method

I try to wright a very simple test code but it still get the same error

public class StaticClass {
public static void echo() {
System.out.println("echo");
}
}

public class NormalClass {
public void echo() {
StaticClass.echo();
}
}

// test file
@RunWith(PowerMockRunner.class)
@PrepareForTest({StaticClass.class})
public class NormalClassTest {
@Test
public void test() throws Exception {
PowerMockito.mockStatic(StaticClass.class);
new NormalClass().echo();
PowerMockito.verifyStatic(StaticClass.class);
}
}

Can somebody please tell me am I missing something in migration ?

Reply all
Reply to author
Forward
0 new messages