Mockito's Mock Methods | Baeldung
www.baeldung.com › mockito-mock-methodsJul 31, 2022 · The simplest overloaded variant of the mock method is the one with a single parameter for the class to be mocked: public static <T> T mock(Class<T> classToMock) We'll use this method to mock a class and set an expectation: MyList listMock = mock(MyList.class); when(listMock.add(anyString())).thenReturn(false); Then we'll execute a method on the mock: