Friday, June 24, 2005


i have started exploring the world of Mock Objects. I am working on an web services based application where I need to write unit tests for only the consumer part of the webservices, i.e., the client side of things. I started out by reading the seminal "Mock Roles, Not Objects".

As I started understanding tha paper the thing which struck me the most was the idea of "Tell, Don't Ask". I guess this one key thinking very neatly summarises the basis of Mock Objects. The idea here is instead of doing something like
one should do
and let the dog decide what this means.

I quote verbatim from the paper: "If we concentrate on an object’s external interactions, we can test it by calling one of its services and tracking the resulting interactions with its neighbours. To summarise, we test an object by replacing its neighbours with objects that test that they are called as expected and stub any behaviour that the caller requires. These replacements are called mock objects. We call the technique of TDD with mock objects, Mock Objects."
This is the essencce of the paper as far as I could tell.

I will write more as I dig deeper into this. And Thanks Rohan, I am "keeping the spirit up."


Post a Comment

<< Home