PowerMockito私有方法doThrow stubbing

时间:2015-03-04 10:29:57

标签: java junit mockito powermockito

private int privateMethod(Object o, boolean b) throws Exception

-

PowerMockito.doThrow(new Throwable("Just a throwable")).when(spy, "privateMethod", Mockito.any(), Mockito.any());

-

org.mockito.exceptions.misusing.UnfinishedStubbingException: 
Unfinished stubbing detected 

我已经尝试将any()切换为anyObject()等。 但我得到了存根问题......

错误在哪里?

1 个答案:

答案 0 :(得分:0)

org.mockito.Matchers.anyBoolean匹配器为我工作。

anyObjectany与原语不匹配。