Zapobiegaj stubbingowi metody równej
Chciałbym przetestować moją metodę equals () klasy, ale wydaje się, że Mockito wywołuje wersję stub za każdym razem. Mój test jest następujący;
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);
Wiem, że nie mogę podać metody równości, co oznacza, że Mockito powinien nazywać moją prawdziwą implementację, ale tak nie jest.
Próbowałem również tego:
when (adapter.equals(any()).thenCallRealMethod()
ale mam taki sam wynik.