State Transition Testing - TwoGears/hakomo-guides GitHub Wiki

State Transition Testing is helpful where you need to test different system transitions.Any system where you get a different output for the same input, depending on what has happened before, is a finite state system. A finite state system is often shown as a state diagram. State Transition Testing is a black-box test design technique in which test cases are designed to execute valid and invalid state transitions. This technique is useful when we have sequences of events that occur and conditions that apply to those events.State-Transition diagrams are excellent tools to capture certain system requirements, namely those that describe states and their associated transitions. These diagrams then can be used to direct our testing efforts by identifying the states, events, and transitions that should be tested. Together, these define how a system interacts with the outside world, the events it processes, and the valid and invalid order of these events. The advantage of a state-transition table is that it lists all possible state-transition combinations, not just the valid ones. When testing critical, high-risk systems such as avionics or medical devices, testing every state-transition pair may be required, including those that are not valid. Creating a state-transition table often unearths combinations that were not identified, documented, or dealt with in the requirements. It is highly beneficial to discover these defects. Using a state-transition table can help detect defects in implementation that enable invalid paths from one state to another. The generally recommended level of testing using state-transition diagrams is to create a set of test cases such that all transitions are exercised at least once under test.

  • Basic parts of State Transition Diagram
    • The states that the software may occupy (Eg: open/closed or funded/insufficient funds) - Persists until something external happens, usually triggering a transition. A state can persist for an indefinite period;
    • The transitions from one state to another ;
    • The events that cause a transition (closing a file or withdrawing money) - Occurs, either instantly or in a limited, finite period. It is the something that happens. The external occurrence that triggers the transition;
    • The actions that result from a transition (Eg: an error message or being given your cash) - The response of the system during the transition. An action, like an event, is either instantaneous or requires a limited, finite period.
  • The testing model typically has 3 entities
    • State Transition Diagrams
    • State Transition Trees
    • State Transition Table
  • Coverage Criteria:
    • Visiting every state and traverse every transition
    • At least one test covers every row in a state transition table
    • At least one test covers each transition sequence of N or less length.