State Transition Testing and its Cases
State Transition Testing and its Cases
State Transition testing is a black box software testing technique in which the Changes in input conditions cause state changes in the Application under Test (AUT). It is a helpful technique where there is a need to test different System transitions (ex: Login attempt upto max. three times with the wrong password and then Block the account.)
In a Finite state system, we can insert the same input to obtain a different output and that truly depends on what has happened in the previous state.
It helps to analyze the behavior of an application under test for different input conditions in a sequence. It needs to insert both positive and negative input test values and to record the system behavior.
Components of the State Transition
- States: The defined state of the system and all the other sequence of states.
- Transition: The Transition can be defined as change from one state to another state due to the occurrence of an event.
- Events: The Event can be defined as the cause due to which the transition in states occurred.
- Actions: The result or outcome of a certain transition of the states.
State Transition Table
In the above State Transition Table, you can observe that all the valid states are listed on the left side of the table and the cause of the events are on the top row.
Each cell represents the state of the system that will change according to the event that occurs.
In S1 state, if you enter a correct password then you will be taken to the state S4 (Successfully Login).
Or, if you have entered a wrong password in the first attempt you will be taken to state S3 i.e. the 2nd Attempt.
And, after the 3rd time entry of the wrong password, the Account will be blocked i.e. state S5.
We can derive a test case on such scenario
Preconditions:
- The user should be on the ‘Sign In’ screen.
Steps:
- Enter registered Email ID in the Email field.
- Enter an Incorrect password in the Password field.
- Click on the ‘Sign In’ button.
- Repeat this for more than 3 times.
- Observe the result.
Expected Result:
- The user account should be blocked and the ‘Sign In Error’ popup with the text ‘Your account has been blocked….’ should display if the user tries to login with the incorrect password more than 3 times.
Pros and Cons of State Transition Technique
Pros:
- This technique provides a pictorial or tabular representation of the system behavior which helps in effective coverage and understanding of the system behavior.
- It provides a better testing technique to verify that all the conditions are covered and the results are captured.
Cons:
- As it requires defining all the possible states of a system. So, it is good for the smaller systems but it fails in case of the large systems as there can be an exponential progression in the number of states.
- Also, we can’t rely on this testing technique every time as this technique cannot be used if the system is not a finite system i.e. not in sequential order.