top of page

What is State Transition testing?


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.


Human language:

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. State transition testing is used where some aspect of the system can be described in what is called a ‘finite state machine’ in which system transitions are needed to be tested. Each transition occurs with the help of a specific event.

This simply means that the system is explained as a finite number of different states (open, waiting, first try, second try, etc.), and the transitions from one state to another are determined by the rules of the "machine", that is, the system itself. This black box testing technique provides either a pictorial/tabular representation of the system behavior that will allow a tester to complete as well as understand the system behavior.

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).

Each cell then represents a state event pair. The content of each cell indicates which state the system will move to when the corresponding event occurs while in the associated state.

The most important thing about using state transition testing is that we reveal the internal behavior of the system. 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.

After we have visualized all transitions, we just execute particular paths from the diagram as test cases.

Life example:

Let's take a look at the example of using a State transition testing

Example 1: State transition diagram

Imagine that our development team builds a checkout of any online store.

Checkout is the most important component of any website, and it should be tested as thoroughly as we can.

The requirements for our checkout are:

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

Let's see how it looks on it:

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.

Example 2: A tabular representation

A tabular representation of the system behavior base on the first example will be:

Where in the first column we see all states of our system, in the second column, are displayed events that lead to transition. The third column displays positive and negative validation, and the last column indicates the state of the system after the event happened.

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.

State transition testing is used where some aspect of the system can be described in what is called a ‘finite state machine’ in which system transitions are needed to be tested. Each transition occurs with the help of a specific event. This simply means that the system is explained as a finite number of different states (open, waiting, first try, second try, etc.), and the transitions from one state to another are determined by the rules of the "machine", that is, the system itself.

281 views

Recent Posts

See All
bottom of page