How would you test a workflow whose behaviour depends on its current state?
Answer
Model the states, allowed events, resulting transitions and forbidden transitions. Cover valid paths, invalid events from each relevant state, terminal states and recovery or timeout behaviour.
Strong answer includes
- states, events and transitions
- invalid transitions
- recovery and terminal states
Practical example
For an order that moves through New, Paid, Shipped, Delivered and Cancelled states, a tester builds a state diagram and checks valid paths like New to Paid to Shipped, but also tries invalid transitions such as shipping a Cancelled order or paying twice for the same order. They also verify that a payment timeout in the Paid-pending state correctly reverts the order to New instead of leaving it stuck.