State Transition Testing
Japneet Sachdeva
Become a successful SDET with my Road To Full Stack QA Courses, Guides & Newsletters
ISTQB definition:
State transition testing (finite state testing) - a black-box test technique using a state transition diagram or state table to derive test cases to evaluate whether the test item successfully executes valid transitions and blocks invalid transitions.
What I understand?
In software testing, ensuring that applications behave correctly as they transition between different states is crucial. State transition testing is a black-box testing technique that focuses on validating these state changes, making it particularly effective for systems where outputs depend not only on current inputs but also on previous states.
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.
A state transition diagram consists of four basic parts:
- States that the software might get - a condition in which a system is waiting for events;
- The transitions from one state to another - change from one state to another as a result of the event;
- The events that cause a transition - Input that may cause a transition;
- The actions that result from a transition - operation initiated by a transition.
In this type of testing, both positive and negative input values are provided and the behavior of the system is observed. In order to see the total number of combinations of states and transitions, both valid and invalid, use a tabular representation of the system behavior. The state table lists all the states down one side of the table and all the events that cause transitions along the top (or vice versa)
If this type of testing is done carefully, there would be no surprises from the end users regarding unsteady states. State transition testing covers all the conditions that the system can handle, therefore it gives the proper representation of its functionality in order to identify whether any state of the system is left uncovered or not in the test cases.
Example:
Checkout consists of 4 steps:
- 1 step with the possibility to add user data;
- 2 step with the possibility to add shipping and payment method;
- 3 step with the possibility to accept terms and use and confirm the payment;
- 4 step - with the details of status after buying the product.
The user is able to proceed to the second step only after inputting valid user data in the corresponding fields, to the third step only after inputting valid shipping and payment method data in the corresponding fields, and to the fourth only after the order has been placed successfully.
Based on our requirements, we can test our checkout with the help state transition diagram In which we display all the states, transitions, and events which trigger them, and also actions that will be a result of these transitions
As you can see, this diagram consists of:
5 states
- Product in the bag;
- First checkout step;
- Second checkout step;
- Third checkout step;
- Fourth checkout step.
Transitions between each state
Events that cause a transition
4 Positive
- Click on the bag;
- Input valid user data;
- Input valid Shipping and Payment method data;
- Accept the terms and conditions.
4 Negative
- Input invalid user data;
- Input invalid Shipping and Payment method data;
- Do not accept the terms and conditions;
- There is not enough money on the card to pay.
And actions that result from a transition will be
- The first checkout step is opened;
- The second checkout step is opened;
- The third checkout step is opened;
- The fourth checkout step is opened.
Conclusion
So, if you are asked at an interview: What is State Transition testing? The best way to answer is:
State Transition testing - is a Black-box testing technique that is performed to check the change in the state of the application after applying different input conditions passed in a sequence. It focuses on the input given to the system, the state it travels to, and the output we receive from it.
-x-x-
Become SDET & Future SDET Manager + 950+ Q&A Bank: Link
2024 950+ QA Automation Q&A + Free Practice Apps, Question Bank with answers for SDETs + Practice your skills: Link
#japneetsachdeva
"Senior QA Lead with 10+ Years of Experience | Mastering Excellence in Software Quality & Elevating Team Dynamics"
3 个月This is such an important concept in software testing. Transitioning between states can uncover critical issues if not tested properly.
Looking for change on Scrum /Test lead/Associate PM
3 个月Useful explanation. I knew definition but never Applied.