I get a null pointer exception after bullying. Please find my project structure.
I am trying to use TDD here, which means I have a service interface, but not an actual implementation. To test the listPets () method, I clearly know that its using the service to get a list of pets. But my intention here is to test the listPets () method of the App class, so I'm trying to make fun of the service interface.
The listPets () method of the App class using the pet service. Therefore, I am mocking this part using mockito.
Mockito.when(petService.listPets()).thenReturn(list);
But when the unit test runs, perService.listPets () throws a NullPointerException , which I mocked at this Mockito.when code. Could you help me with this?
source share