I am just starting with Mockito and I just want to do something like :
public class Test { public void clearList(List l){ doVeryLOOOONGDatabaseCallll(); l.clear(); return; } } /// ... Test test = mock(Test.class); Mockito.when(test.clearList(any(List.class))).then( l => l.clear()); Have some hint to do the trick? Thank you for your help!
clearList(List l)is called.doVeryLOOOONGDatabaseCallll()notclearList(). Mocking isn't about changing behavior inside methods; it's making it so you don't need external dependencies.