Tag: mockito

  1. Mocking method with wildcard generic return type

    There are several cases where construction when().thenReturn is not suitable during Unit tests. One of then generic return type. I have faced such issue, let's take a look. There is a method in interface declaration: public interface FooInterface { public Iterable<? extends SomeClass> getList(); ... } Implementation looks like this:…

    on mockito java junit doReturn generic wildcard

  2. Mocking of callback function via Mockito

    I suppose, the first case every developer learn in Mockito is mocking methods with a return value. Construction when().thenReturn() covers 80% of all case in a code I suppose. Next thing what developers learn in Mockito is mocking of void method. doAnswer().when() usually used for this purpose. But…

    on java mockito tests