I currently am faced with the following test case: I want to mock the abstract ActorRef class from akka:
@RunWith(MockitoJUnitRunner.class)
public class ConstraintBuilderTest {
@Mock
ClassANeededByClassB a;
@InjectMock
ClassB b;
@Before
public void setUp(){
Mockito.when(a.equals(a)).thenReturn(true);
}
//tests go here
}
I know that the mockito page says it cannot mock equals. So are there any ideas on how to mock that?
The equals method on ClassB uses ClassANeededByClassB to check its equality.
What I could think of to do is to inject a into the mocked class b. How best to proceed?
Please be aware that the classes come from a framework which I cannot change, so I cannot change its code to add a setter or anything like that.
ClassB bwith a mock ofa? is this what you want? - Debojit Saikia