Definition of mocking

When I read what Uncle Bob wrote today about how he usually hand-rolls his mocks it not only stirred up trouble. It also reminded me of why I hate the mock vs not mocking debate. First of all there is a clear difference in what people mean when they talk about mocking. I kind of covered it earlier but here is a recap; Either you mean you’re using mock objects or you’re using a mocking framework. Most often people mean the latter. And there shouldn’t be a religious debate over this because most people would agree that you should always use the best tool for each task. No tool can be used for everything. Also the definition of done is pretty common in the agile world (where I think mocking is used more than outside the agile world) and if we think having a clear understanding of what done means, we should also remember to make sure we define what we’re talking about before we get all excited and start argument for either side.

That said I can only say what I think (again). Mocks are powerful and can easily be used wrong (see link to my previous post above). The use of mocking frameworks also tends to make the code harder to understand, sometimes for everybody and sometimes only to people who aren’t familiar with the framework syntax. That is an important point to me. Tests should always be easy to understand and to me that means hand-rolling mocks most of the time.

Comments (0)

Skip to main content