Ian Cooper brought up an interesting point on the altdotnet mailing list recently, around the language used to describe Mocks, or more accurately his preference for the term Test Double over my use of the generic term Mock.
In most areas of development I can often be considered a language perfectionist, for example calling something a Unit Test when it is *clearly* an Integration Test drives me nuts - but when it comes to Mocks, Stubs, Fakes, Spys, or the rather more generic Test Doubles ... I just can't get passionate about the language.
This all started a while ago, when people started using the term mock, but really it wasn't a mock - or more often they used the term mock when referring to what many mock frameworks call a Strict Mock, just one type of mock.
Martin Fowler long ago posted on a clarification of the terminology around mocking, and xUnitPatterns has a fuller description. The distinction that Gerard Meszaros introduced was to use the term Test Double to describe all of these things we use to help us test our code. Fakes, Spys, Mocks, Dummys ... all just a type of Test Double.
Now language is important. Very important. As Ian pointed out in his email, most arguments centre around a misunderstanding of the terminology involved - I'm sure the world would be a nicer place if language was universal and could not be interpreted differently by different people, but then it would be a linguistically poorer place for it too.
In development, language is something that is vital to good communication of what are often very complex technical concepts. We evolved the languages of patterns and principles to allow us to avoid confusion and misunderstandings, and most areas of development have their own specific language terminology.
But, with this one area of testing I have a problem with the terminology, because the term that I hear from developers on a daily basis is "mocking", not "test doubles". And when terminology enters the common language, it is very hard to replace it with a new term just because you prefer it. I'm sure that Test Double describes the concept better, and I'm sure that it is important to have some distinction between Mocks and Fakes, but in my experience, that is not how developers refer to these things.
It is much easier to say "we can mock this out" than it is to say "we can create a test double here", the first is just more natural in the English language. So the term "mock" has become almost a defacto term for what Martin Fowler et al refer to as a Test Double, whilst also being a Mock with a capital M for describing the Mock that most mock frameworks create.
So, much as I might like to be a language perfectionist on this one, I tend to just use the term mock, and leave the decision as to whether it is a Mock, Fake, Stub or Whatever to the point I actually code it. So far nobody has misconstrued Mock to mean "you must use a mocking framework", or at least not anyone to whom the concepts of mocking are not entirely new anyway, in which case much more clarification is needed in any case.
06-11-2008 10:25 AM