Testing Sequences of State Transitions

A stateful test exercises several events in order and verifies which effects persist across the events.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Choose a sequence that accesses a corner
  2. Check invalid orderings
  3. Observe meaningful outcomes after every transition
  4. Test a sequence that reaches the same state by different paths

Choose a sequence that accesses a corner

A reminder can start enabled, be disabled, and then receive a second disable command. Check its state after each command and count notifications if they are observable. Idempotent transitions explain the promised repeat behavior.

Check invalid orderings

For draft, submitted, and confirmed states, attempt confirmation before submission. Then submit normally. The invalid action should leave enough state for the valid path to continue. Use the transition table to choose supported and rejected steps.[1]

Observe meaningful outcomes after every transition

A work item starts ready, becomes running on claim, then complete on finish. A repeated finish can remain complete under an idempotent contract. Starting with finish should return an invalid-transition result without changing ready. See state transition tables.

Ready → claim → Running
Running → finish → Complete
Complete → finish → Complete under stated retry rule
Ready → finish → rejection

Test a sequence that reaches the same state by different paths

Cached fields and event histories can differ even when a final status matches. Check what the model promises about observable history. To find a defect, compare the expected and actual update immediately after each transition.

References

  1. Python Software Foundation, unittest: Unit Testing Framework ↩