Decision Tables & State Transitions

Continuing on from the previous post, some additional specification based test techniques.

Decision tables testing

Decision table testing can be applied to test the behaviour of logical conditions found within the specification.

The decision table lists all possible inputs and all the corresponding outputs. Each column in the table corresponds to a distinct business rule. There may be a large number of inputs, but not necessarily a large number of test cases – it’s dependent on the valid business rules, not the possible combinations of conditions.

For example, a hotel chain booking system gives a free bottle of wine to first time guests and loyal customers. If the guest has a birthday during their stay, they receive a complimentary box of chocolates only if they have not received free wine. Loyal customers celebrating a birthday receive 2 bottles of wine. All customers with less than 3 stays per year receive a survey after checkout.

Creating a decision table for the above policy gives 5 rules:

ConditionsRule 1Rule 2Rule 3Rule 4Rule 5
First stayFalseTrueFalseFalseFalse
Long term customer (4+ stays / year)FalseFalseTrueFalseTrue
Customers birthday during stayFalseFalseTrueTrue
Actions
Free bottles of wine112
Box of chocolatesYes
Customer surveyYesYesYes

Rule 2 requires 2 test cases (a customer with and without a birthday, that should both receive 1 free bottle of wine, and the survey)

State transition testing

State transition testing is a visual technique to examine the state an entity can be in, and what actions cause the state to change (the transitions). Test cases are derived for each transition, not just each state the entity can be in.

In this simple example, the state of an eCommerce site shopping basket dictates what recommendations the user sees based on recent purchases as well as what has been recently added and removed, so all of those actions will change the recommendations.

Arrows show what actions change the state of the basket.

A minimal set of tests to trigger all states and exercise all transitions would then be to traverse through state transitions ‘ABACD’.