Archive

Archive for the ‘Mocks’ Category

SimpleMock

March 22nd, 2007

I recently had occasion to demonstrate how to write a very lightweight mocking framework. The result was SimpleMock. SimpleMock does four things:

  1. Reports failure when no expectations are set
  2. Reports failure when expectations are not met
  3. Reports failure when unexpected calls are found
  4. Succeeds when all expectations are met
  5. Allows you specify if expectations are positionally sensitive or not

SimpleMock will not do the following:

  1. Set return values for functions
  2. Mock parameters
  3. Or any of the other really cool things that PascalMock1.1 will do

Tests are included in the archive. These will show you how to use it.

Download the code here: SimpleMock.zip

Updated to added behavior #5 above. I recently had a reason to not care in what order method expectations are called.

Mocks, XP