Skip to content
SDETRole
SDETRole

Order status state transitions

intermediate State transition testing Challenge 6 of 10

An order service tracks each order through a small workflow. The function receives the order’s current state and an event, and returns the new state, or invalid transition when the event is not allowed in that state. Write tests that expose every bug in eight buggy implementations.

Requirements

  • A new order can be paid (paid) or cancelled (cancelled).
  • A paid order can be shipped (shipped) or cancelled (cancelled).
  • A shipped order can be delivered (delivered).
  • delivered and cancelled are final states: no event changes them.
  • Every other combination of state and event returns invalid transition.

Expected output

Tests that match the specification and expose all 8 planted bugs.

Function under test

nextStatus(state, event) → status

  • state one of new, paid, shipped, delivered, cancelled
  • event one of pay, ship, deliver, cancel

How your tests are checked

  • ○Every expected value agrees with the specification
  • ○Your tests expose all 8 planted bugs

The correct implementation is the oracle. A bug counts as caught when one of your valid tests gives a different result on the buggy copy than on the correct code.

testsMutation-tested in your browser
#statechoiceeventchoiceexpected statusRemove
1
1 test

Ctrl/⌘ + Enter to check tests · your tests are saved in this browser

Results

Check your tests to see which planted bugs they catch.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →