views:

23

answers:

1

Im learning Mockito and in chapter 16 they say you should not use partial mocking in new system.

I disagree, for example in one of my actions i use partial mocking for static framework methods, sql calls, etc. I extracted the stuff into methods and then mock it in tests. Most of those methods are specific to this action and wont be call from other actions, so it not worth to extract special components. I agree that you shouldn't using partial mocking in frameworks, but not in hard to mock actions. What are minuses of using partial mocking in web-app?

+1  A: 

Mocking allows to isolate SUT by factoring out DOC using mock objects (with both stubs and mocks). By partially mocking DOC you introduce dependency into the test that is not desirable. Basically, your test may fail due to problems in DOC that are not target of the test.

grigory
good point, you might be right
01