Mockito and void methods on mock objects

SO I have
class TestFoo {

}
TestFoo s1 = Mockito.mock(TestFoo.class);
TestFoo s2 = Mockito.mock(TestFoo.class);

The Mockito doc “Real Partial Mocks” says to do this:

when(mock.someMethod()).thenCallRealMethod();

we get the error

“The method when(T) in the type Mockito is not applicable for the arguments (void)”

After 1/2 hour of hunting I found a hint, and refactored:

Mockito.doCallRealMethod().when(s1).assertEquals(s2);

This entry was posted in Computers, Software and tagged , , , . Bookmark the permalink.

Leave a Reply