An Annotated Assortment on Mockist Testing
30 November 2011
Most of us read blog posts every day. We read them, take an idea out of them and then, most of the time, forget about them. Some of them are stashed away in the back of our minds, ready to jump out if we face a related problem.
A precious few of them, however, we keep thinking back to without a specific reason.
I’ve bitten by the “mockist” testing bug when I read this one a while ago. It expresses a contrarian opinion about how to test Rails applications which struck me as odd at the time. That’s probably the reason I read it several times.
A few weeks ago I watched Gregory Moeck’s Why You Don’t Get Mock Objects and I was stung by the same bug only more deeply, this time.
Using that video as a starting point I then roamed Gregory’s blog for more and felt like I was beginning to grasp it. Now, obviously, I’m at the beginning of this journey and still have a lot of teeth-cutting to do. Nevertheless, I want to share with you the gems I’ve found so far.
Gregory’s blog has a very good primer on the difference between stubs and mocks: “Stubbing is Not Enough”. I’d even go as far as to claim that it explains its subject better than Martin Fowler’s classic “Stubs Are Not Mocks”, although that latter goes into more detail and is a definite must-read, too.
James Golick has another great piece that drives home the point better than his first post I mentioned: “On Mocks and Mockist Testing”.
Along comes Avdi Grimm with his strict sounding “Demeter: It’s not just a good idea. It’s the law.” , with a very interesting discussion in the comments. The same gentleman wrote “Making a Mockery of TDD” in which he touches on the concept of using mocks as a design tool.
Nick Kallen’s “Why I love everything you hate about Java” is clearly provocative and definitely worth to contemplate on. It is also the only one of the bunch that does not use Ruby (but Scala) for the code examples.
Finally it seems like the fountainhead in the matter is the “Growing Object-Oriented Software, Guided by Tests” book by Steve Freeman and Nat Pryce. I’ve only gotten until putting it on my reading list so please chime in if you did read it.
Please, also pipe in if there are any materials in the subject you’d recommend. It would also be cool to see open source projects that extensively use mocks for testing, the only one I found so far is friendly.