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
neworder can be paid (paid) or cancelled (cancelled). - A
paidorder can be shipped (shipped) or cancelled (cancelled). - A
shippedorder can be delivered (delivered). deliveredandcancelledare 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
stateone of new, paid, shipped, delivered, cancelledeventone 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
| # | statechoice | eventchoice | expected status | Remove |
|---|---|---|---|---|
| 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.