verifyPrivate上的PowerMock MethodNotFoundException,方法接受Class

时间:2011-07-14 04:12:49

标签: java mockito powermock

PowerMock抛出org.powermock.reflect.exceptions.MethodNotFoundException: No methods matching the name(s) methodInsideFoo were found in the class hierarchy of class com.something.Something.

测试代码:

    Something spied = spy(new Something());

    doNothing().when( spied, "methodInsideFoo", "ABC", Some.class );

    spied.foo( "ABC", Some.class );

    verifyPrivate( spied ).invoke( "methodInsideFoo", "ABC", Some.class );

这就是我试图模仿的方法:

protected void methodInsideFoo ( String a, Class b )
{
    System.out.println("Should not see me");
}

但如果我删除Class(第二个参数),它就可以。我错过了什么吗?