1
although stubbed methods may return mocks, you cannot inline mock creation (mock()) call inside a thenReturn method (see issue 53)
我下面的https://code.google.com/p/powermock/wiki/MockitoUsage
PowerMockito.mockStatic(MyUtil.class);
Mockito.when(MyUtil.compareVersion("1","2")).thenReturn(200);
此外,我想這個嘲笑類偏,也有其他人在這個類中的方法,這是我不想嘲笑,他們應該照常運行。
詳細的異常:
org.mockito.exceptions.misusing.UnfinishedStubbingException:
Unfinished stubbing detected here:
-> at org.powermock.api.mockito.internal.PowerMockitoCore.doAnswer(PowerMockitoCore.java:31)