Calls to Mockito.when
should always be accompanied by a call to a method like
thenReturn
.
when(mock.get()).thenReturn(answer); // correct
when(mock.get()) // oops!
Similarly, calls to Mockito.verify
should call the verified method outside
the call to verify
.
verify(mock).execute(); // correct
verify(mock.execute()); // oops!
For more information, see the Mockito documentation.
Suppress false positives by adding the suppression annotation @SuppressWarnings("MockitoUsage")
to the enclosing element.