When a team comes under pressure to get software delivered, quite often any effort spent writing tests is seen as detracting from the delivery push. It’s easy to understand why this is, because tests are just more code. So we could write less code, and get the product out quicker, right?

Luckily, even teams that dislike testing, are aware of the improved cost of quality that it brings. This makes them think about the optimum number of tests to write without holding things up. What is the bare minimum?

To keep things lean, we should just be thinking about testing the stuff we must have, and the stuff that we can’t stand to have. The rest of the stuff is detail that will either split off into another lower priority story, or just things that will never get done, and nobody will care.

When prompted for an example of this recently, I invoked some Monty Python, and called for the Holy Hand Grenade of Antioch. It is probably the first agile user story, and a great example of specifying a product by describing how you should and shouldn’t use it.

To explain, for non Python fans, a medieval king encounters a terrible beast (that looks a lot like a small white rabbit). He summons a monk from his entourage to bring forth the Holy Hand Grenade, and a cleric reads from an ancient holy book, the instructions for the use of said weapon. The important part being…

“First shalt thou take out the Holy Pin. Then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out.”

This is a great description for someone wanting to put acceptance criteria on, or write behavioural tests for such a device. Here’s my punt at a story for the Holy Hand Grenade.

As a knight who is in a spot of bother
I want to use the holy hand grenade
So that I can complete my quest

What I must have
“The number of the counting shall be three”
Given I have pulled the holy pin
When I count to three and lobbeth the grenade
Then my enemy is blown to tiny bits

What I can’t stand to have
“Four shalt thou not count”
Given I have pulled the holy pin
When I count to four
Then I am blown to tiny bits

“neither count thou two, excepting that thou then proceed to three”
Given I have pulled the holy pin
When I count to two and stop there
Then I am blown to tiny bits

“Five is right out”
Given I have pulled the holy pin
When I count to five
Then I must cut down the biggest tree in the forrest with a herring

That is enough tests, for anything else would be too silly.