Mocking vs. Spying in mocking frameworks

后端 未结 7 1292
执念已碎
执念已碎 2020-11-28 20:24

In mocking frameworks, you can mock an object or spy on it. What\'s the difference between the two and when would/should I use one over the other?

7条回答
  •  隐瞒了意图╮
    2020-11-28 20:46

    Mockito warns that partial mocking isn't a good practice and you should revise your Object Oriented architecture. Spy (or partial mocking) is recommended to test legacy code.

提交回复
热议问题