简体   繁体   中英

Mock method using mockito, NOT PowerMockito

I can not understand how to mock a method like bellow, using on mockito(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 .

Try...

Mockito.any(Class.class)

...instead of...

Mockito.any(Agent.class)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM