I would like to test my class' equals() method but Mockito seems to be calling the stub version every time. My test is as follows;
PluginResourceAdapter adapter = mock (PluginResourceAdapter.class);
PluginResourceAdapter other = mock (PluginResourceAdapter.class);
when(adapter.getNumberOfEndpointActivation()).thenReturn(1);
when(other.getNumberOfEndpointActivation()).thenReturn(0);
boolean result = adapter.equals(other);
assertFalse(result);
I know I cannot stub the equals method which means Mockito should be calling my real implementation but its not.
I have also tried this:
when (adapter.equals(any()).thenCallRealMethod()
but I get the same result.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…