Mocks Objects

Martin Fowler has posted a new essay called Mocks Aren’t Stubs. It’s a good examination of the difference between using Mock objects to stub out behaviour vs. using Mocks for behaviour verification. Fowler also notes the distinction between what he calls classical vs. mockist testing.

I approached unit testing in the classical fashion until I came to Intelliware. Now that I’ve been exposed to mock objects, I really like the idea of using them for behaviour verification (and obviously, find them useful for stubbing out objects). I think Kent Beck said that Unit Tests are a Rosetta Stone to your code… I suppose comments also help ;-). Mock objects definitely make it easier to explain your code in a Unit Test.

It's only fair to share...
Share on Facebook
Tweet about this on Twitter
Share on LinkedIn

Leave a Reply