I have to test a rest api in spring application which has dependency on service class and it also has dependency on dao class. I have created controller instance with @InjectMocks, service with @Spy and dao with @Mock. In my current scenario, the api that I'm testing calls a method in within spy and the called method calls a method in mock. If I don't use spy then the test doesn't work properly and if used then the instance of dao is not injected into service. In this context what should I need to do inject mocked object of dao into spy object?
0
votes
Are you trying to unit test the controller code?
- Alexandru Marina
yes! I'm trying to verify that dao instance is called through service instance while accessing rest api.
- msucil