Give students examples for each as follows:
"We pronounce it /s/ when the word ends with…"
Here we can begin to see the difference between mocks and stubs. If we were writing a test for this mailing behavior, we might write a simple stub like this.
"We pronounce it /iz/ or /is/ when the word ends with…"
To explore test doubles a bit more, we need to extend ourexample. Many people only use a test double if the real object isawkward to work with. A more common case for a test double would be ifwe said that we wanted to send an email message if we failed to fillan order. The problem is that we don't want to send actual emailmessages out to customers during testing. So instead we create a testdouble of our email system, one that we can control andmanipulate.
So if mockist testing sounds appealing to you, I'dsuggest giving it a try. It's particularly worth trying if you arehaving problems in some of the areas that mockist TDD isintended to improve. I see two main areas here. One is if you'respending a lot of time debugging when tests fail because they aren'tbreaking cleanly and telling you where the problem is. (You could alsoimprove this by using classic TDD on finer-grainedclusters.) The second area is if your objects don't contain enoughbehavior, mockist testing may encourage the development team tocreate more behavior rich objects.
…take a look at the following tags:
I also suffer from the disadvantage of not trying mockist TDDon anything more than toys. As I've learned from Test DrivenDevelopment itself, it's often hard to judge a technique withouttrying it seriously. I do know many good developers who are very happyand convinced mockists. So although I'm still a convinced classicist,I'd rather present both arguments as fairly as I can so you can makeyour own mind up.