Mocks and Stubs

  • Mock when you need to test that the code *does* something to another object
  • Stub when the code needs to call a complicated query on another object
  • Try to avoid either wherever possible :-)

Trying to make sure I remember some lessons by writing them down. I’ve grokked the absolute necessity of unit tests for quite a while now, but after a hell of a lot of practice I finally seem to be getting better at *writing* them.