[英]Mock method using mockito, NOT PowerMockito
I can not understand how to mock a method like bellow, using on mockito(NOT PowerMockito) 我不明白如何在模拟上使用像波纹管这样的方法(NOT PowerMockito)
public boolean sendSignal(final Class<? extends IAgent> agentClass, final MessageLite signal)
I can NOT do it as follows - 我不能这样做如下-
Mockito.when(plumProxyService.sendSignal(Mockito.any(Agent.class), Mockito.any(MessageLite.class))).thenReturn(true);
Where - 哪里-
public abstract class Agent implements IAgent{
...
..
}
You are creating a expectation for any Agent
when really you want any Class
. 当您真正想要任何
Class
时,您正在为任何Agent
创造期望。
Try... 尝试...
Mockito.any(Class.class)
...instead of... ...代替...
Mockito.any(Agent.class)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.