lundi 11 juillet 2016

How to inject mock object in spy object?

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?

Aucun commentaire:

Enregistrer un commentaire