An overview of best practices with Mock, using Nova code as an example.

Sean Dague, Dan Smith, and Jay Pipes (and Jay Pipes’ pug, Winnie) discuss mock best practices. They address common slip-ups and problems, lay out several different options for style, and explain what a good test unit looks like.

http://www.youtube.com/watch?v=jCWtLoSEfmw

The start the conversation with a discussion on what a good test unit looks like. The general consensus is that small and explicit tests are preferred. Other best practices include:

  • Generally, stick to having a unit test only test a single method
  • When in doubt, test less, not more, within a single test method
  • A good unit test will highlight crappy code, interfaces and assumptions

They also discussed styles for mocking, and argued against the big nested context style and instead recommended the nested test method that uses the method decorator mocks or using a fixture for the test.

To learn more, watch the video, check out the slide deck, and check out the notes on the etherpad.