Course outline
Decision table tool
Every combination of the conditions, an action for each, then the rules merged down to the test cases you need.
Business rules hide many cases in a few sentences. "WELCOME5 takes 5.00 off a basket of 25.00 or more, once per account" mixes three conditions, so eight combinations, and a requirement rarely says what happens in each of them. A decision table makes every combination visible, so none is forgotten and none is tested twice.
List the conditions; the tool writes every rule (one per combination). Give each rule its action, and it merges the rules whose action does not depend on a condition, leaving one test case per rule that is left.
Use the tool
One per line: its name for yes or no, or "Name: value, value" for other values. Up to 64 rules.
8 rules. Write the action of each one.
| Rule | Code is valid | Basket is 25.00 or more | Code used before by this shopper | Action |
|---|---|---|---|---|
| 1 | Y | Y | Y | |
| 2 | Y | Y | N | |
| 3 | Y | N | Y | |
| 4 | Y | N | N | |
| 5 | N | Y | Y | |
| 6 | N | Y | N | |
| 7 | N | N | Y | |
| 8 | N | N | N |
Merged: 4 rules, so 4 test cases.
| Rule | Code is valid | Basket is 25.00 or more | Code used before by this shopper | Action |
|---|---|---|---|---|
| R1 | Y | Y | Y | Refuse: already used |
| R2 | Y | Y | N | Take 5.00 off |
| R3 | Y | N | - | Refuse: the basket is under 25.00 |
| R4 | N | - | - | Refuse: the code is not valid |
How the method works
Each condition is yes or no, or one of a few values. The full table has one rule for each combination: two conditions make four rules, three make eight. Writing an action for every rule is where the gaps in a requirement show: when nobody can say what should happen, ask before you test.
Two rules with the same action that differ in one condition only, and between them take all its values, become one rule with "-" for that condition: it does not matter there. The tool repeats this until nothing more merges. Each merged rule is one test case.
- One condition per line: its name for yes or no, or "Name: value, value" for more values.
- Write the action of every rule in the full table.
- Test each merged rule once: choose values that match it, and check its action.
A worked example on Cedar Books
The welcome code WELCOME5 at Cedar Books takes 5.00 off a basket of 25.00 or more, once per account (the coupon list on the practice shop page). Three conditions make eight rules; merged, four cases remain:
| Rule | Code is valid | Basket is 25.00 or more | Code used before by this shopper | Action |
|---|---|---|---|---|
| R1 | Y | Y | Y | Refuse: already used |
| R2 | Y | Y | N | Take 5.00 off |
| R3 | Y | N | - | Refuse: the basket is under 25.00 |
| R4 | N | - | - | Refuse: the code is not valid |
Rule R3 holds whatever the shopper did before: an under-25.00 basket is refused either way. Rule R4 holds whenever the code is not valid. Four tests instead of eight, and no case missed.