State Transition Testing
Some features behave differently depending on what happened before. State transition testing checks those flows.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Draw a state transition diagram
- Build a state table
- Test valid and invalid transitions
- Apply it to workflows
Explanation#
A state is a condition the system is in (Pending, Paid, Shipped). An event triggers a transition to another state.
Test every valid transition, and also invalid ones — the system should refuse them gracefully.
Typical uses: order workflows, account lockouts, approval processes, subscription status.
Code example: Order status workflow#
pay ship deliver
Pending ─────────► Paid ─────────► Shipped ─────────► Delivered
│ cancel │ cancel (refund)
▼ ▼
Cancelled ◄───────────┘
Valid transitions to test: Pending→Paid, Paid→Shipped, Shipped→Delivered,
Pending→Cancelled, Paid→Cancelled (refund issued)
Invalid transitions to test: Delivered→Cancelled, Cancelled→Shipped, Pending→Shipped
Five valid and three invalid transition tests cover the workflow’s rules.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- Identify states and events from the requirements.
- Draw transitions between states.
- Test every valid transition.
- Attempt invalid ones and expect a clear refusal.
Real-world use case#
An e-commerce admin should never be able to ship a cancelled order — a state transition test proves it.
Common mistakes#
Cancellations and invalid moves often have the bugs.
Check refunds, emails and stock updates on each transition.
Best practices#
- Draw the diagram first
- Cover every transition at least once
- Test invalid transitions
- Verify side effects
Remember this#
State + event → new state.
Valid and invalid transitions.
Check side effects.
Practice exercise#
Your task: An ATM card is blocked after 3 wrong PINs. List the states.
Show solution
Start → 1st wrong → 2nd wrong → Blocked; a correct PIN from any non-blocked state → Access granted.
Mini quiz#
Which is an invalid transition in the order workflow above?
Want more? Practise all Manual Testing MCQs · Manual Testing interview questions
My notes#
Saved in this browser.