State Transition Testing: Diagram, Table, Examples (2026)
State Transition Testing explained with diagrams, state tables, worked examples, and 0/1/N-switch coverage. Interview-ready guide for QA engineers.

Last updated: July 17, 2026 · 11 min read · By Avinash Kamble, reviewed by Priyanka G.
State Transition Testing is the black-box technique for any feature that has modes — a shopping cart moving through empty → active → checkout → paid, an OTP code moving through sent → valid → used → expired, an approval workflow moving through draft → submitted → approved → published. If you skip this technique, you ship the class of bugs where a user re-triggers a state and the system silently corrupts. This guide gives you the diagram, the state table, the coverage levels, and interview-ready examples.
Pair with decision table testing and the black box testing complete guide.
Key takeaways
- Use it whenever the feature has clearly defined modes and legal / illegal transitions.
- Model with a state diagram AND a state table — they catch different mistakes.
- 0-switch coverage = every valid transition once; N-switch coverage = every sequence of N+1 transitions.
- Catches the “illegal transition” bug class that other techniques routinely miss.
1. What is State Transition Testing?
State Transition Testing is a black-box technique that models the system as a finite set of states connected by transitions, then designs tests to cover every legal transition (and, ideally, every illegal one). Documented as an experience-based / specification-based technique in the ISTQB Foundation syllabus.
2. When to use it
- The feature has clearly defined modes: cart, workflow, session, wallet, subscription, OTP, approval.
- The requirement mentions phrases like “can only be… from…” or “transitions to…”.
- You have caught “wrong state” bugs in production before (double-charging, expired OTP still valid, re-approval loops).
- Compliance requires proof that illegal transitions are blocked.
3. The four modelling elements
- States — the modes the system can be in (e.g. Empty, Active, Checkout, Paid).
- Transitions — the allowed moves between states (Empty → Active on add-item).
- Events — what triggers a transition (add-item, remove-item, pay).
- Actions — what the system does during the transition (update total, send email).
4. Worked example: shopping cart
States: Empty, Active, Checkout, Paid.
add-item go-to-checkout pay
Empty ─────────▶ Active ─────────────▶ Checkout ─────▶ Paid
▲ │ │
│ remove-last │ │ cancel
└──────────────────┘ └──────▶ ActiveState table:
| Current state | Event | Next state | Action |
|---|---|---|---|
| Empty | add-item | Active | Insert item, recalc total |
| Active | add-item | Active | Insert item, recalc total |
| Active | remove-last | Empty | Clear cart |
| Active | go-to-checkout | Checkout | Freeze cart, quote shipping |
| Checkout | cancel | Active | Unfreeze cart |
| Checkout | pay | Paid | Charge card, place order |
| Paid | pay | — | ILLEGAL — must be blocked |
| Empty | go-to-checkout | — | ILLEGAL — must be blocked |
5. Coverage levels: 0-switch, 1-switch, N-switch
- 0-switch (all transitions): exercise every valid transition once. Minimum bar.
- 1-switch (all pairs): exercise every pair of consecutive transitions. Catches bugs where the sequence matters.
- N-switch: exercise every sequence of N+1 transitions. Rarely used outside safety-critical.
Aim for 0-switch coverage plus the top 5 pairwise sequences you know your users actually run.
6. Testing illegal transitions
The biggest ROI of state-transition testing is proving illegal transitions are blocked. From the cart example: what happens if a user posts pay against an already-Paid cart? Or triggers go-to-checkout against an empty one? These are the bugs that leak into production. Add one negative test per illegal cell in your state table.
test('cannot pay for an already-paid cart', async ({ request }) => {
const cart = await createPaidCart();
const res = await request.post(`/api/cart/${cart.id}/pay`);
expect(res.status()).toBe(409);
const body = await res.json();
expect(body.error).toMatch(/already paid/i);
});7. Automating state transition tests
Store the state table as data, then loop:
const validTransitions = [
{ from: 'Empty', event: 'add-item', to: 'Active' },
{ from: 'Active', event: 'go-to-checkout',to: 'Checkout' },
{ from: 'Checkout', event: 'pay', to: 'Paid' },
];
for (const t of validTransitions) {
test(`${t.from} --${t.event}--> ${t.to}`, async () => {
const cart = await seedCartInState(t.from);
await fireEvent(cart, t.event);
expect(await getCartState(cart)).toBe(t.to);
});
}Data-driven state loops fit Playwright, Postman, and any modern test runner.
8. Interview prep
Frequent at 2+ years. Prompts: “Design state transition tests for an ATM”, “Draw the state diagram for an OTP flow”. Rehearse on the AI Mock Interview and prep the whole set on the 3-year Q&A.
9. Your 24-hour action step
Pick one stateful feature in your app. Draw the state diagram in 20 minutes. Fill in the state table. Add one test per legal transition and one per illegal cell. You will find at least one uncovered illegal transition — that's a production incident prevented. Benchmark comp on the QA Salary Guide.
Frequently asked questions
1.What is state transition testing?
2.When should I use state transition testing?
3.What is the difference between state transition testing and decision table testing?
4.What are 0-switch, 1-switch, and N-switch coverage?
5.How do I automate state transition tests?
Practice these questions
Run a live QA mock interview tailored to this topic and get per-skill scoring in minutes.
Was this article helpful?
Keep building your QA edge
Pillar guides- SDET Career RoadmapQA to SDET career pathYear-by-year plan from QA to senior SDET — skills + projects.
- AI Mock Interviewpractice these questions with our AI mock interviewLive AI-powered mock interviews with rubric feedback.
- ATS Resume ReviewATS Resume ReviewFree AI ATS scoring with rewrite suggestions.
Continue reading

What Is Software Testing? The Complete 2026 Guide for QA Engineers
16 min read
Types of Software Testing — Functional vs Non-Functional (25+ Types Explained, 2026)
18 min read
Software Testing Life Cycle (STLC) — 6 Phases with Entry & Exit Criteria (2026 Guide)
14 min readJoin the QA Community
Connect with fellow testers, share job leads, and get career advice.
Stop Reinventing the Wheel. Upgrade Your QA Arsenal.
Take your testing skills from beginner to Lead Engineer. Supercharge your daily workflow with our premium digital resources.
- Ready-to-use testing strategy templates
- Advanced API & UI automation guides
- ⏱️ Save 10+ hours a week on test planning