CR Sardar
CR Sardar

Reputation: 1018

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{
...
..
}

Upvotes: 0

Views: 59

Answers (1)

BretC
BretC

Reputation: 4199

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)

Upvotes: 2

Related Questions