Mock objects

Saturday 31 July 2004This is more than 20 years old. Be careful.

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.

Comments

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.