Test levels and methods
State transition testing
State transition testing derives test cases from a state model: it checks that the system reacts correctly to events in every state and moves to the right next state.
Also known as: state-based testing, state machine testing
When states matter
Many systems behave differently depending on their history. A payment is open, authorised, completed or cancelled. A device is off, on standby, active or in a fault state. The same event, such as a button press, has a different effect in each state.
The approach
- Write down states and transitions as a diagram or table
- Choose test cases so that every state and every valid transition occurs at least once
- Deliberately check invalid transitions: what happens if the “stop” command arrives while the device is “off”?
The third step in particular uncovers many defects, because these cases are rarely considered during development.
Typical uses
State transition testing is standard for protocols, user interfaces, workflows and ECUs, whose firmware is almost always built as a state machine.