State machine-based testing is a systematic approach to testing software systems that can be modelled as finite state machines. It focuses on testing state transitions and ensuring the system behaves correctly as it moves between different states. State machine-based testing is particularly effective for systems where behaviour depends heavily on history and context, such as communication protocols, workflow systems, and user interfaces with complex navigation paths.

How it works

Modelling the system

  • Identify all possible states the system can be in
  • Define valid transitions between states
  • Identify events/inputs that trigger state transitions
  • Define expected outputs/actions for each transition

Key elements

  • States: Distinct conditions or situations the system can be in (e.g., logged out, logged in, admin mode)
  • Transitions: Movements from one state to anothe
  • Events: Inputs that trigger transitions
  • Actions: Outputs or operations that occur during transitions

Example

Test design

Test design for state machines

  • Exhaustive
    • Every non-cyclic path
    • Exercise each loop and every transition at least once.
  • Every state at least once
    • [valid card, valid pin, choose transaction, finish transaction]
    • [valid card, invalid pin]
    • [invalid card]
  • Every transition at least once
    • [valid card, valid pin, choose transaction, finish transaction]
    • [valid card, valid pin, choose transaction, another transaction, cancel transaction]
    • [valid card, invalid pin]
    • [invalid card]
  • All n-transition sequences

Back to parent page: Software Testing

Web_and_App_Development Software_Testing Blackbox_Testing SOFT3202 State_Machines