State Transition Diagrams and Tables:
Representation of State Transitions will be in the form of ‘State Transition Diagrams and Tables’. A ‘State Transition Diagram’ shows all valid transactions in pictorial format. The ‘State Transition Table’ shows both valid and invalid transactions in tabular forms.
State, Event, Transition and Actions:
An event occurs through a condition. A condition is nothing but an input value given to a field. The event results in a transition from one state to another.
Thus, a change of state results in an action (OUTPUT).
So, In other words, a ‘State Transition Testing’ is a “technique used to test the ability of software to enter and exit from specified states through a set of valid and invalid transactions.”
A state diagram consists of:
The State Transition Diagram for a Login Screen is as shown below:
User account gets locked after three unsuccessful attempts. If the user gives correct login credentials in any attempt, then it has to display the homepage.
The State Transition Table for the above scenario is defined as below:
The test cases are as follows:
The State Transition applies to any transactional software like embedded software, web software, control systems etc.
State Transition Coverage:
State Transition Coverage % = Number of identified states or transitions tested / The total number of states or transitions in the test object.
‘n-Switch Coverage’ represents the ‘Number of Transactions Covered’.
If we test a valid sequence of one successive transaction at least once, then we call it as 100% 0-Switch Coverage
If we test a valid sequence of two successive transactions at least once, we call it as 100% 1-Switch Coverage
And so on…
“Round-trip coverage” is applicable where sequences of transitions form loops. So, we will achieve a 100% round-trip coverage when we test all loops from each state back to the same state.
The minimum acceptable coverage is to make sure that every state is visited and also every transaction is traversed. Sometimes, a transaction can be traversed more than once in order to execute another transaction in line.
Pictorial and Tabular Representation helps to understand the system effectively.
Gives a better idea on the overall test coverage.
We cannot use this technique if the system is not sequential.
It works very well for small systems, but gets complicated as the system gets bigger with multiple interfaces.
ISTQB Sample Question:
Question 1 :
Based on the given State Transition Diagram of a switch ,which of the following test case is invalid?
OFF to ON
ON to OFF
FAULT to ON
ON to FAULT
Answer: Option 3: FAULT to ON
Explanation: Here, options 1, 2 and 4 are valid as the transitions occur based on the diagram. Option 3 is not valid as the transition is either ON to FAULT Or FAULT to FAULT and not FAULT to ON.
Question 2 :
Given the following state transition, which of the following series of state transitions below will provide 100% 0-switch coverage.
Answer: Option 1 : A,B,E,B,C,F,D
Explanation: Transitions A,B,E,B,C,F,D cover all the states at least once.