25 September 2006

Like a Fire Drill

David Saff has come up with an entertaining metaphor for using mock objects: the School Fire Drill. There are a couple of ways to test that your pupils are prepared for a fire. You can set light to the school: the alarm will go off, everyone will troop outside, and the fire brigade will turn up and douse the building in water. Now you've tested the whole system so you can be sure that everything works. Of course, you'll have also lost your job but that's another matter. Alternatively, you can coordinate with the fire station and just set off the alarm. You can check that the pupils don't rush the exits and that everyone is accounted for. You can try a couple of different assembly points without much cost. You can keep your job. The rest of the system can be tested separately: you can check the alarm on Wednesdays at 11:00, and the fire brigade will have its own drills. Every once in a while, some building really will catch fire which will confirm that things work end-to-end. (In software, of course, you can run functional tests more predictably).


Tester said...

Where can I find the papers we used to have in MockObjects.com?

I tried looking for http://www.mockobjects.com/papers/jdbc_testfirst.html

Steve Freeman said...

We're getting around to restoring things.

Actually, I'm not sure I want to repost that one since I think it's problematic. These days, I'm much more interested in mocking internal types (to be able to drive the design) rather than external types.