Are mocks better than stubs?

前端 未结 6 933
梦毁少年i
梦毁少年i 2021-02-13 09:01

A while ago I read the Mocks Aren\'t Stubs article by Martin Fowler and I must admit I\'m a bit scared of external dependencies with regards to added complexity so I would like

6条回答
  •  广开言路
    2021-02-13 09:43

    Never mind Statist vs. Interaction. Think about the Roles and Relationships. If an object collaborates with a neighbour to get its job done, then that relationship (as expressed in an interface) is a candidate for testing using mocks. If an object is a simple value object with a bit of behaviour, then test it directly. I can't see the point of writing mocks (or even stubs) by hand. That's how we all started and refactored away from that.

    For a longer discussion, consider taking a look at http://www.mockobjects.com/book

提交回复
热议问题