Updated July 1, 2023
What is State Transition Testing?
Software Testing Principles are defined and followed for ensuring the successful Testing process, find and fix the defects, and to not miss any requirements provided by the customer. The seven principles of Software Testing that are essentially to be followed for all the types of software testing encircle ‘Early testing’, ‘Testing shows presence of defects’, ‘Defect clustering’, ‘Pesticide paradox’, ‘Testing is context dependent’, ‘Exhaustive testing is not possible’, ‘Absence of errors fallacy’.
When to Use State Transition Testing?
- State Transition testing is used when so ever the tester is testing an application considering the finite set of the input values.
- It can also be used whenever tester is testing the sequence of events which take place in an application under test, that is, this would make the tester test application behaviour for the sequence of the input values.
Also, it can be used whenever a system that is under test has got the dependency on the events or values in past.
State transition diagram demonstrates the states in the form of texts that are boxed and the transition is demonstrated through the arrows. State transition diagram is also referred to as the State Chart or also Graph. It is as well quite useful in the identification of the valid transitions.
How to Perform State Transition Testing (Include Examples)
Let us discuss how to perform state transition testing with the help of examples.
Example 1:
Let us assume the functionality of the ATM system wherein in case the user enters an invalid password for three consecutive times account will get locked.
However, in the same system in case the user enters a valid password in any of consecutive three attempts the user would get logged in successfully. However, in case the user enters an invalid password for a first or second time the user is asked to re-enter the password. And at last, in case the user enters the incorrect password for the 3rd time his account will get locked.
When so ever user enters right PIN he is logged in with the state that is Access granted and in case the keys in the wrong password he is given the next try and if he repeats his action for the 3rd time the blocked state of account is reached.
State Transition Table
Correct PIN | Incorrect PIN | |
D1) Start | D5 | D2 |
D2) 1st try | D5 | D3 |
D3) 2nd try | D5 | D4 |
D4) 3rd try | D5 | D6 |
D5) Access Granted | – | – |
D6) Account blocked | – | – |
As provided in the above table whenever user keys in the right PIN, the state is moved to D5 which is called Access granted state. But in case user keys in the wrong pin he is transitioned to the next state. However, in case he does the same for the 3rd attempt as well, he will be in the state where his account gets blocked.
Example 2:
In the reservation login screen of flights assume that you need to enter the correct agent name as well as password in order to get inside flight reservation application.
It would give us access to the application with the right password and user name, but do you know what would happen in case you entered the wrong password.
This application too permits only three attempts, and in case the users enter the wrong password in the 4th attempt system the application would close automatically.
State Graphs is useful for determination of the valid transitions that needs testing. For this case, testing along with the right pin as well as with a wrong pin is mandatory.
We can also use the State Table for determination of system transitions that are invalid.
For the State Table, each and every valid state are provided on the left-hand side of the table, also events that make them occur are on above.
All of the cells denotes the system of state would eventually move to whenever the corresponding event takes place.
Let us take an example. When you are in the D1 state, then you enter the correct password, then you are moved to D6 state which is Access Granted State. In case we have keyed in the wrong password in the first try then you would be moved to D3 state or given a 2nd Try.
In a similar manner, we can predict the remaining states.
We have highlighted two of the states that are invalid with the help of this method. Assume that we are in the state S6, meaning, we are logged in into the application already, and afterwards we open the other instance of the reservation of flight, then input either right or wrong passwords for that same agent only. The response of the system for such condition has to get testing done.
Advantages
Few advantages are as given.
- This black box testing technique provides either pictorial/tabular representation of the system behaviour that will allow a tester to complete as well as understanding the system behaviour in an effective manner.
- By using this testing, The technique tester is able to verify that all of the conditions are covered by using this particular testing. In addition, the results are as well captured.
Disadvantages
Following are the disadvantages given.
- The most basic disadvantage of state transition testing technique is we cannot ever depend or rely on this procedure every other time. Let us take an example. In case the system infinite system, that is, it is not in a sequential order then we cannot use this technique.
- Second disadvantage of state transition testing is that we need to mention every possible state of the system. Although it is correct for all the smaller ones, it, however, comes down to larger ones since there exists exponential progression when it comes to how many states exist.
Recommended Articles
This has been a Guide to State Transition Testing. Here we discuss basic concepts, examples, advantages and disadvantages of State Transition Testing in detail. You may also look at the following article to learn more –