Hard-Coded Mock Objects vs Mocking Framework

后端 未结 6 1960
悲&欢浪女
悲&欢浪女 2020-12-16 19:18

I\'m curious as to what method people like to use for mocking and why. The two methods that I know of are using hard coded mock objects and a mocking framework. To

6条回答
  •  温柔的废话
    2020-12-16 19:59

    Some distinguish between mocks and stubs. A mock object may verify that it has been interacted with in the expected way. A mocking framework can make it easy to generate mocks and stubs.

    In your example, you've stubbed out a single method in an interface. Consider an interface with n methods, where n can change over time. A hand-stubbed implementation may require more code and more maintenance.

提交回复
热议问题