Mock vs. Spy in Mockito http://ift.tt/1xglFnz When Mockito creates a mock – it does so...

Please Visit: http://ift.tt/1ajReyV



Mock vs. Spy in Mockito

http://ift.tt/1xglFnz

When Mockito creates a mock – it does so from the Class of an Type, not from an actual instance. The mock simply creates a bare-bones shell instance of the Class, entirely instrumented to track interactions with it.



On the other hand, the spy will wrap an existing instance. It will still behave in the same way as the normal instance – the only difference is that it will also be instrumented to track all the interactions with it.

@Spy

List<String> spyList = new ArrayList<String>();

List<String> spyList = Mockito.spy(new ArrayList<String>());






from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1N8RN48

via LifeLong Community

No comments:

Post a Comment