#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Black Box Techniques

State Transition Testing

What is State Transition Testing?

State transition testing is a black box technique used for systems whose behaviour depends on their current state and historical inputs, verifying that the system moves correctly between different states.

Key Concepts

  • States: Distinct conditions the system can be in (e.g., "Logged Out," "Logged In," "Locked").
  • Transitions: The valid changes from one state to another, triggered by specific events.
  • Events: Actions or inputs that cause a state transition (e.g., entering a correct/incorrect password).

Test Design Using State Diagrams

Testers use state diagrams or state tables to visualise all valid states and transitions, then derive test cases that cover valid transitions, invalid transitions, and sequences of transitions (e.g., testing an account lockout after multiple failed login attempts).

Worked Example: Login With Account Lockout

Take a rule many apps follow: three wrong passwords in a row lock the account until an administrator unlocks it. The states are:

  • S0 Logged out, no failed attempts
  • S1 Logged out, one failed attempt
  • S2 Logged out, two failed attempts
  • S3 Locked
  • S4 Logged in

The state table

A state table lists every state against every event. Empty or "no change" cells are where invalid transitions hide, and they are just as important to test.

Current stateCorrect passwordWrong passwordLogoutAdmin unlock
S0S4S1Not allowedNo change
S1S4S2Not allowedNo change
S2S4S3Not allowedNo change
S3Stays S3, locked messageStays S3Not allowedS0
S4Not applicableNot applicableS0No change

Deriving Test Cases From the Table

IDStartEventsExpected end state and check
TC1S0Correct passwordS4, dashboard opens
TC2S0Wrong, wrong, wrongS3, lockout message shown
TC3S2Correct password, logout, wrong passwordS1, counter was reset by the successful login
TC4S3Correct passwordStill S3, login refused
TC5S3Admin unlock, correct passwordS4
TC6S0Direct call to logout endpointRequest rejected, still S0

TC3 is the kind of case that finds real bugs. Many systems forget to reset the failure counter after a successful login, so a user who mistypes twice on Monday and once on Friday gets locked out unfairly.

How Much Coverage Is Enough?

  • All states: every state is visited at least once. This is the weakest level.
  • All valid transitions (0-switch): every arrow in the diagram is exercised once. This is the usual minimum for a formal test design.
  • Pairs of transitions (1-switch): every sequence of two consecutive transitions is tested, which catches bugs that depend on history, like the counter reset above.
  • Invalid transitions: each "not allowed" cell is attempted to prove the system refuses it.

The technique fits anything with a lifecycle: order statuses from placed to delivered, ticket workflows in tools such as Jira, ATM sessions, traffic signals, and subscription plans moving between trial, active, paused and cancelled.

Mistakes When Applying the Technique

  • Testing only the happy path through the diagram and skipping invalid events.
  • Ignoring guard conditions, such as "only if the balance is enough", which split one transition into two outcomes.
  • Forgetting time-based events, like a lock that releases automatically after a waiting period or a session that expires.
  • Drawing the diagram from the code rather than the requirement, which copies the developer's mistakes into the tests.

Practical routine: draw the diagram, convert it to a table, fill every empty cell with an expected response, then write one test per valid transition and one per important invalid one.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course