What to do When Mocks Fail

Many years ago, I worked on a project that used Mock Services extensively. We wrote our code against those mocks and all went swimmingly. Then we switched to the real service. That is when things went awry. 

The actual service were far less forgiving then our mock service. It failed for all sorts of non-functional reasons; database field length constraints, null values, empty values, duplicate database values, missing message headers (undocumented in specification), unsupported MIME types… and much more.

It turned out that the Mocks in our code were of little use; they had not achieved their objective.

Solution

Make sure that your mocks mimic every key aspect of actual behaviour on the target system. Otherwise, you will end up with tests that offer you little more than a false sense of security.

I’m not saying this will be easy, but then nothing worthwhile in life ever is. What I will say is that if you put in the effort up-front, your tests will be both useful and valid for the rest of the product lifecycle.

Living the Dream…

…or Epic Fail

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>