State Transition Testing Technique for Testing Complex Applications

In our last article, we saw ‘Cause and effect graph’ test case writing technique. Today let’s move to next dynamic test case writing method – State transition technique.

Note – The test design techniques mentioned here may seem difficult but once you get hold of it, it becomes very easy to implement and reuse, increasing productivity and test coverage.

What is State transition testing technique?

State transition technique is a dynamic testing technique, which is used when the system is defined in terms of a finite number of states and the transitions between the states are governed by the rules of the system.

Or in other words, this technique is used when features of a system are represented as states which transform to another state. The transformations are determined by the rules of the software. The pictorial representation can be shown as:

So here we see that an entity transitions from State 1 to State 2 because of some input condition, which leads to an event and results to an action and finally gives the output.

To explain it with an example:

You visit an ATM and withdraw $1000. You get your cash. Now you run out of balance and make exactly the same request of withdrawing $1000. This time ATM refuses to give you the money because of insufficient balance. So here the transition, which caused the change in state is the earlier withdrawal

What You Will Learn:

State Transition Testing Example in Software testing:

In the practical scenario, testers are normally given the state transition diagrams and we are required to interpret it. These diagrams are either given by the Business Analysts or a stakeholder and we use these diagrams to determine our test cases.

Let’s consider the below situation:

Software name – Manage_display_changes

Specifications – The software responds to input requests to change display mode for a time display device.

The display mode can be set to one of the four values:

The different states are as follows:

Change Mode (CM)

Activation of this shall cause the display mode to move between “display time (T)” and “display date (D)”.

Reset (R)

If the display mode is set to T or D, then a “reset” shall cause the display mode to be set to “alter time (AT)” or “alter date (AD)” modes.

Time Set (TS)

Activation of this shall cause the display mode to return to T from AT.

Date Set (DS)

Activation of this shall cause the display mode to return to D from AD.

State transition diagram is shown as:

Now, let’s move to interpret it:

Here:

1) Various states are:

2) Various Inputs are:

3) Various Outputs are:

4) Changed States are:

Step 1:

Write all the start state.  For this, take one state at a time and see how many arrows are coming out from it.

Let’s put this into our table:



Since for state S1 and S2 there are two arrows coming out, we have written it twice.

Step -2:

For each state, write down their final state.

Put this on the table as output / resultant state.

Step 3:

For each start state and its corresponding finish state, write down the input and output conditions

– For state S1 to go to state S2, the input is Change Mode (CM) and output is Display Date(D) shown below:

In a similar way, write down the Input conditions and its output for all the states as follows:

Step 4:

Now add the test case ID for each test shown below:

Now let’s convert it to formal test cases: 

(Click image to enlarge)

In this way, all the remaining test cases can be derived. I assume the other attributes of the test cases like preconditions, severity, priority, environment, build etc. are also included in the test case.

Conclusion:

Summarizing the steps once again:

  1. Identify the initial states and their final state based on the lines/arrows that are coming out of the initial state
  2. For each initial state, find out the input condition and the output result
  3. Mark each set as a separate test case.

State Transition testing is a unique test approach for testing complex applications, which would increase test execution productivity without compromising on test coverage.

About the author: This is a guest article by Shilpa Chatterjee Roy. She is working in software testing field for the past 8.5 years in various domains.

Want more examples?

If you want more examples of State Transition Testing technique in bigger software applications, please read this post:

=> State Transition Testing Technique Example – Housing Loan Approval Application