If you have any feedback or suggestion please feel free to drop in below comment box. The @InjectMocks annotation makes it easier and cleaner to inject mocks into your code. I see that when the someDao.findMe(someObject.getId.toString()) execute it does NOT trigger my MockDao return statement, but instead tries to evaluate someObject.getId.toString().When I did println in the test … Mock will be created by Mockito. In the following example, we'll create a mocked ArrayList manually without using the @Mock annotation: All new annotations are *only* processed on MockitoAnnotations.initMocks(Object). Mockito Let's test the MathApplication class, by injecting in it a mock of calculatorService. The main issue here is whenever I try to run the test syncLocalOrders_OrderNotEmptySuccessTest (), the code enters to both subscribe and throwable of fun syncLocalOrders (syncOrders: SyncOrders) (this was got by keeping breakpoints.) Void methods can be used with Mockito’s doNothing (), doThrow (), and doAnswer () methods, making mocking and verifying intuitive: However, doNothing () is Mockito's default behavior for void methods. Take a look at the following code snippet. IMHO you need to add a @RunWith (some.mockito.TestSuiteIDontRememberName.class) annotated to the test class. Could you please help me to solve this issue. This also applies to method calls within when (...). In this case, we must remember to make our rule public. In the above code snippet, the MockitoJUnitRunner class is used to check that all the mocks are created and autowired when needed. The @Mock annotation is used to create and inject mocked instances. In you're example when (myService.getListWithData (inputData).get ()) will cause a NullPointerException because myService.getListWithData (inputData) is null - it has not been stubbed before. public class ArgumentCaptor