State transition testing

State transition testing image

What is state transition testing?

State transition testing verifies how a system moves between different states in response to inputs or events. This black-box testing technique maps out system states and the conditions that trigger transitions between them. It's especially valuable for testing authentication flows, workflows, financial systems, and embedded software where behavior depends on the current state.

Do you have any examples of state transition testing?

In an e-commerce checkout process, states might include: 

  • Cart Review → Payment Method Selection → Payment Processing → Order Confirmation

A tester would verify all valid paths (successful payment leads to confirmation) and invalid paths (expired credit card properly returns to payment selection with error message). Another example is a login system where testers validate transitions between states like:

  • Unauthenticated → Credentials Entered → Authentication Processing → Authenticated/Failed

Why is state transition testing important?

State transition testing catches bugs that only appear during specific state changes. It verifies that applications handle sequential operations correctly, prevent unauthorized state access, and maintain data integrity between transitions. 

This testing is crucial for security-critical applications where improper state management could create vulnerabilities. It also improves user experience by ensuring smooth workflows and appropriate error handling.

What are the challenges of state transition testing?

State explosion is the biggest challenge—as systems grow more complex, the number of possible states and transitions increases exponentially. 

Other challenges include:
  • Identifying all relevant states and transitions
  • Creating efficient test cases that maximize coverage
  • Testing timing-dependent transitions
  • Handling complex prerequisite conditions
  • Maintaining test suites as the application evolves

Tools like state tables, directed graphs, and automated test frameworks help manage these challenges.
 
State transition testing is used to check how a system behaves when it moves from one condition to another based on user actions or system events. A common example is an ATM withdrawal. The ATM moves through different states like idle, card inserted, authenticated, and so on, depending on what the user does. Below is a simple breakdown of how state transition applies during an ATM withdrawal process. 

ATM Withdrawal – State Transition Example (Plain Text Format) 

  1. ATM is idle
    → User inserts ATM card
    State changes to: Card Inserted

  2. Card Inserted
    → User enters correct PIN
    State changes to: Authenticated

  3. Card Inserted
    → User enters wrong PIN
    State changes to: Error or Retry

  4. Authenticated
    → User selects "Withdraw Money"
    State changes to: Withdrawal Selected

  5. Withdrawal Selected
    → User enters amount within balance
    State changes to: Processing Withdrawal

  6. Processing Withdrawal
    → Amount is available in account
    State changes to: Dispense Cash

  7. Processing Withdrawal
    → Amount is not available
    State changes to: Show Error Message

  8. Dispense Cash
    → ATM gives money to user
    State changes to: Transaction Complete

  9. Transaction Complete
    → User takes card
    State changes back to: ATM Idle


 
Things you can test:
 
  • What happens if the user enters a wrong PIN three times
  • How the system handles insufficient balance
  • Whether the cash is dispensed only after proper checks
  • What happens if the card is not removed after the transaction


MoT Professional Membership image
For the advancement of software testing and quality engineering
Explore MoT
 What's in the box? Episode 5. image
Software Testing Live: Episode 05
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
Leading with Quality
A one-day educational experience to help business lead with expanding quality engineering and testing practices.
This Week in Testing image
Debrief the week in Testing via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.