Mock objects

Saturday 31 July 2004

The appearance of pMock got me reading about mock objects again. pMock is a mock object library for Python inspired by jMock. Mock objects are a testing methodology whereby an object under test is surrounded by fake implementations of its supporting objects so that the behavior of the tested object can be isolated and minutely observed.

Martin Fowler's article Mocks Aren't Stubs gets into some of the essence of mock objects, and how they differ from stub implementations. As I understand Martin's point, stubs are passive implementations of an interface, while mock objects are active participants in the recording and checking of behavior across the interface.

I've never used mock objects, and they seem quite complicated at first glance. But I'm interested in them because as I write more and more code, I get more and more interested in verifying its correctness automatically, pinning down the corners to control the complexity of all of the change inherent in a large development process.


Add a comment:

Ignore this:
not displayed and no spam.
Leave this empty:
not searched.
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.