Black Box · Specification-Based

State Transition Testing

Model a system as a finite set of states and the events that move it between them. Test every valid transition — and verify that invalid transitions are rejected.

Junior Senior ISTQB CTFL v4.0 — 4.2.4

What it is

Many systems can only be in one state at a time, and move between states in response to events. A bank account is either Open, Frozen, or Closed. A booking is Pending, Confirmed, Cancelled, or Completed. State transition testing ensures all these paths work correctly.

The model has four elements:

  • States — the distinct conditions the system can be in.
  • Events (triggers) — inputs or actions that cause a transition.
  • Transitions — the move from one state to another.
  • Actions — what the system does when a transition occurs.

Building the state model

Start with a state diagram (boxes = states, arrows = transitions labelled with event/action). Then convert it to a transition table for easier test case derivation.

Worked example

Online order lifecycle: an order starts as Pending, can be Confirmed, Dispatched, Delivered, or Cancelled.

Order state transition table
Current StateEventNext StateAction
PendingPayment receivedConfirmedSend confirmation email
PendingCustomer cancelsCancelledSend cancellation notice
ConfirmedStock allocated & shippedDispatchedSend tracking number
ConfirmedCustomer cancelsCancelledInitiate refund
DispatchedDelivery confirmedDeliveredClose order, request review
DeliveredCustomer cancelsInvalidError: cannot cancel delivered order
CancelledPayment receivedInvalidError: order is cancelled

Coverage criteria

There are three main coverage levels:

  • 0-switch (all states) — visit every state at least once. Weakest.
  • 1-switch (all transitions) — exercise every valid transition at least once. ISTQB Foundation standard.
  • 2-switch (all transition pairs) — every consecutive pair of transitions. Strong but expensive.

Testing invalid transitions

A complete test suite also tests transitions that should not be possible. Try to cancel a delivered order. Try to dispatch a cancelled order. These tests verify the system rejects invalid state changes gracefully — not silently, and not by corrupting data.

Real-world value: state transition bugs are nasty to find manually. A user who somehow gets an order into an impossible state can create support nightmares. Model it formally and test the invalid paths explicitly.

ISTQB mapping

ISTQB CTFL v4.0 reference
RefTopicLevel
4.2.4State Transition TestingCTFL Foundation
FL-4.2.4 K3Apply state transition testing to derive test casesFoundation LO
FL-4.2.4 K3Achieve specified coverage levelsFoundation LO

NZ example — RealMe identity verification

RealMe is New Zealand’s government identity verification service (used by IRD, NZTA, MSD). A RealMe account moves through states during verification.

RealMe account — state transition table
Current StateEventNext StateNotes
UnverifiedSubmit documentsPendingDocuments under review
PendingDocuments acceptedVerifiedIdentity confirmed
PendingDocuments rejectedUnverifiedResubmit required
VerifiedFraud flag raisedSuspendedSuspicious activity detected
SuspendedFraud clearedVerifiedAccount reinstated
VerifiedClosure requestedClosedAccount closure
UnverifiedJump to VerifiedInvalidNo documents submitted — must be impossible
SuspendedSelf-close accountInvalidAdmin-only action; user cannot self-close while suspended

All-transitions coverage requires a test case for each valid transition. The two invalid transitions must also be tested — verify the system rejects them gracefully, not silently.

Try it yourself

NZ library book loan system — state transition table

A library book can be in one of four states: Available, On Loan, Reserved, or Overdue. There are exactly 6 valid transitions. For each row, select the From state and To state, and type the triggering event.

# From state Event (what triggers the change?) To state
All 6 valid transitions:
#From stateEventTo state
1AvailableMember borrows bookOn Loan
2On LoanMember returns bookAvailable
3OverdueMember returns bookAvailable
4On LoanDue date passes / book not returnedOverdue
5AvailableMember reserves bookReserved
6ReservedMember borrows / reservation fulfilledOn Loan