verifyPrivate 上的 PowerMock MethodNotFoundException 方法接受类
PowerMock 抛出 org.powermock.reflect.exceptions.MethodNotFoundException:在类 com.something.Something 的类层次结构中找不到与名称 methodInsideFoo 匹配的方法。。
测试代码:
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");
}
但是如果我删除类(第二个参数),它就会起作用。我错过了什么吗?
PowerMock throws org.powermock.reflect.exceptions.MethodNotFoundException: No methods matching the name(s) methodInsideFoo were found in the class hierarchy of class com.something.Something.
.
Test code:
Something spied = spy(new Something());
doNothing().when( spied, "methodInsideFoo", "ABC", Some.class );
spied.foo( "ABC", Some.class );
verifyPrivate( spied ).invoke( "methodInsideFoo", "ABC", Some.class );
And this is the method I'm trying to mock:
protected void methodInsideFoo ( String a, Class b )
{
System.out.println("Should not see me");
}
But if I remove Class (2nd parameter), it works. Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能与以下内容有关:
http://code.google.com/ p/powermock/issues/detail?id=342
PowerMock、mockito、验证静态方法
Could this be related to:
http://code.google.com/p/powermock/issues/detail?id=342
PowerMock, mockito, verify static method