In TDD, there are always more potential scenarios to test, other than the “happy path” of desirable behavior. We need a way to decide how far to go.
This is often a question of risk assessment. Having a framework for thinking about risk can be useful. Consider this framework that has two dimensions: Likelihood and severity. Crossing these produces a four-quadrant matrix.
- Very likely and highly severe. Example from life: Being in a car accident. They happen all the time, and can kill people. These are worth taking action on, like installing seat belts and airbags.
- Unlikely and trivial. Example: My neighbor’s mail being delivered to my house. This almost never happens, and if it does I just take it next door.
- Unlikely and highly severe. Example: Being struck by lightning. Most of us will never experience this, but it would be bad if it happened. You might install lightning rods on your home, but that’s a judgement call.
- Very likely and trivial. Example: Stubbing your toe. This happens to everyone on a regular basis, but it’s only annoying. I don’t bother to wear steel-toed shoes around the house.
Most risks exist somewhere within these dimensions, and in each case identifying where they land can be helpful in making decisions on which additional tests to write.
This is Scott Bain. Visit us at www.netobjectives.com.