verifyStatic get NotAMockExcption from mockito

已查看 433 次
跳至第一个未读帖子

Wade Hong

未读,
2019年5月30日 10:58:492019/5/30
收件人 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 ?

回复全部
回复作者
转发
0 个新帖子