I have a method :
public class Sender{ public Object send(Object param){ Object x; ..... return (x); } } I want to write a unit test for this method using Mockito such that the return type value is based on the class type of the paramter. So I did this:
when(sender.send(Matchers.any(A.class))).thenReturn(value1); when(sender.send(Matchers.any(B.class))).thenReturn(value2); but the return value irrespective of the parameter class type is always value 2. How do it get this to return value 1 for class A type argument and value 2 for class B type argument.