# How to test a state transition

> Design tests for a workflow’s starting state, event and expected next state. Check accepted and refused actions with a library loan example.

Source: https://cueapril.com/knowledge/how-to/test-state-transitions
Updated: 2026-12-02
Index: https://cueapril.com/llms.txt

## How do you test a workflow whose rules depend on its current state?

Model each case as a starting state, an event, any condition on that event and the expected next state. Check both accepted and refused transitions, including the visible result and any stored side effects.

## Exercise the transitions in the model

A useful state model names decisions the product actually makes. A timeout can be an event even when no person clicks anything.

1. Draw the states and label each allowed transition with its event. Ask about timeouts, repeated actions and conditions that block a change.
2. Create each starting state deliberately. Trigger one event and check the resulting state and its observable effects.
3. Exercise a refused transition and a meaningful sequence. Check that refusal leaves important state intact and that a later action sees the right history.

## Worked example: A returned library loan

Returning an active loan moves it to returned and adds one available copy. Repeating the return should leave the inventory unchanged under the agreed rule. A test that checks only for a friendly ‘already returned’ message could miss a second increase in the available count.

## Try it on your pull request

Choose a change in your repository and tell Cue April what should happen. Review the proposed checks before they run.

[Try Cue April on your repository](https://app.cueapril.com/sign-up/?next=%2Fquality-start)

## Related reading

- [State transition testing](https://cueapril.com/knowledge/definitions/state-transition-testing)

- [Retries and idempotency in software testing](https://cueapril.com/knowledge/explanations/retries-and-idempotency)

- [Choose where to test each risk](https://cueapril.com/knowledge/playbook/design-the-test-portfolio)

[Browse the Knowledge base](https://cueapril.com/knowledge)
