I often see the same methods being verified as the methods being mocked in Mockito (example below). Is there any added benefit to call Mockito.verify() in these cases?
//mock method
FooService fs = mock(FooService.class);
when(fs.getFoo()).thenReturn("foo");
//method under test
fs.doSomething();
//verify method
verify(fs).getFoo();
The method should fail if fs.getFoo() is not called. So why call verify? I see the benefit if you need to use ArgumentCaptor in the verify to assert the parameters; besides the ArgumentCaptor case, is it just unnecessary?
Aucun commentaire:
Enregistrer un commentaire