0 and 1 - Switch Coverage in State Transition Testing?

Gaurav Verma picture Gaurav Verma · Feb 28, 2017 · Viewed 8.7k times · Source

This question is not programming related but related to one of test case design the technique. State Transition Diagram technique provides Test coverage by identifying test conditions via N-1 switch transitions. I am confused about how to calculate the 0-switch and 1-switch coverage.

Adding screenshot of an example. Can anyone please explain how this can be solved? Thank you in Advance.

Question in screenshot Diagram for this Question

Answer

Marco Filippone picture Marco Filippone · Mar 13, 2017

The number of 0-switch from a state equals to the number of the transitions of length 1 starting from that state. In this case you have:

  • ACT-ACT;
  • ACT-ACC;
  • ACT-DIS;
  • ACT-CLO.

So, from Activated there are 4 transitions of length 1.

1-switch coverage from a state equals to all the transitions of length 2 starting from that state. You can build up from what you found in the 0-switch case, knowing which states you can reach from Activated in 1 transition. Just compute all the 0-switch transitions from each of these 4 states:

  • ACT: (as computed earlier) ACT-ACT; ACT-ACC; ACT-DIS; ACT-CLO -> 4;
  • ACC: ACC-ACT; ACC-CLO -> 2;
  • DIS: DIS-ACT; DIS-CLO -> 2;
  • CLO: CLO-DIS; CLO-ACT; CLO-REM; CLO-ACC -> 4.

In total, there are 12 1-STs.

But this is without considering the constraints in the second part of the exercise description.

"If a claim in state Accepted has been Closed it can only be restored to the same state Accepted." -> it does not matter for the exercise, since we start from the state Activated.

"If a claim in state Activated has been Closed it can only be restored to state Activated." -> this constraint rules out ACT-CLO-ACC.

So, in the end, you have 11 valid 1-STs.