Skip to content
← All CTFL learning objectives

CTFL 4.2.4: Use state transition testing to derive test cases

K3

Syllabus section 4.2.4

5 original PrepBench practice questions for learning objective 4.2.4 of the CTFL 4.0 syllabus. Try the examples below and check each answer against its syllabus reference.

Practice questions

Question 1

An order moves through the states New, Paid, Shipped and Cancelled. The state table below gives the target state for each event; a dash means the transition is not valid. State New — event pay: Paid; event ship: -; event cancel: Cancelled State Paid — event pay: -; event ship: Shipped; event cancel: Cancelled State Shipped — event pay: -; event ship: -; event cancel: - State Cancelled — event pay: -; event ship: -; event cancel: - How many transitions must the test cases exercise to achieve 100% valid transitions coverage?

  1. 3
  2. 4
  3. 6
  4. 12
Show answer
  • 3Three is the count if the two cancel transitions are treated as one.
  • Correct answer: 4The table contains four filled cells, so four valid transitions.
  • 6Six would count some empty cells, which represent invalid transitions.
  • 12Twelve is every cell in the table, which is the basis of all transitions coverage.

In valid transitions coverage the coverage items are the single valid transitions, and 100% coverage requires the test cases to exercise all of them. The table shows four filled cells: New to Paid on pay, New to Cancelled on cancel, Paid to Shipped on ship, and Paid to Cancelled on cancel. Every other cell is a dash and so is an invalid transition, which valid transitions coverage does not require.

Syllabus section 4.2.4

Question 2

A media player has the states Stopped, Playing and Paused. Its valid transitions are: From Stopped — event play: to Playing. From Playing — event pause: to Paused; event stop: to Stopped. From Paused — event play: to Playing; event stop: to Stopped. The player starts in the state Stopped. Which of the following event sequences consists only of valid transitions?

  1. play, stop, pause, play
  2. play, pause, stop, pause
  3. pause, play, pause, stop
  4. play, pause, play, stop
Show answer
  • play, stop, pause, playAfter play and stop the player is Stopped again, where pause is not valid.
  • play, pause, stop, pauseAfter play, pause and stop the player is Stopped, where pause is not valid.
  • pause, play, pause, stopThe player starts in Stopped, where the first event pause is not valid.
  • Correct answer: play, pause, play, stopStopped to Playing to Paused to Playing to Stopped are all valid.

Starting in Stopped, play moves the player to Playing, pause moves it to Paused, play moves it back to Playing, and stop returns it to Stopped. Every step of that sequence is a transition the model allows. Each of the other sequences reaches a state in which its next event has no valid transition: pause and stop are not valid events in the state Stopped.

Syllabus section 4.2.4

Question 3

A document workflow has these states and valid transitions: Start state: Draft Draft, event submit -> Review Review, event approve -> Published Review, event reject -> Draft Published, event revise -> Draft Published, event archive -> Archived Which pair of tests, each starting in Draft, achieves the highest valid transitions coverage?

  1. Test 1: submit, reject, submit, approve, archive; Test 2: submit, reject
  2. Test 1: submit, approve, revise, submit, approve; Test 2: submit, reject, archive
  3. Test 1: submit, reject, submit, approve, archive; Test 2: submit, approve, revise
  4. Test 1: submit, approve, revise, submit, approve; Test 2: submit, approve, archive
Show answer
  • Test 1: submit, reject, submit, approve, archive; Test 2: submit, reject80%: all four states are reached, but revise is never exercised — all states coverage is the weaker criterion.
  • Test 1: submit, approve, revise, submit, approve; Test 2: submit, reject, archive80%: all five event names appear, but archive is fired in Draft, where it is invalid, so it exercises nothing.
  • Correct answer: Test 1: submit, reject, submit, approve, archive; Test 2: submit, approve, reviseCorrect, 100%: the two tests exercise all five valid transitions, each event fired in a state where it is valid.
  • Test 1: submit, approve, revise, submit, approve; Test 2: submit, approve, archive80%: both transitions out of Published are exercised, but reject is never fired, so that transition is missing.

In valid transitions coverage, also called 0-switch coverage, the coverage items are the single valid transitions, and coverage is the number exercised divided by the five this workflow has: submit, approve, reject, revise and archive. A run stops where it fires an event that is not valid in the current state, and that event exercises no transition. Scoring each pair gives 4/5 = 80% for the first, 4/5 = 80% for the second, 5/5 = 100% for the third and 4/5 = 80% for the fourth, so the third pair achieves the highest coverage.

Syllabus section 4.2.4

Original PrepBench practice material, not official exam questions or exam dumps. PrepBench is independent and is not affiliated with or endorsed by ISTQB®.

Glossary terms in this chapter