All insights

Quality Engineering / Field note

Design workflow tests around state changes

Use a simple approval workflow to turn business rules into durable, diagnosable automated checks.

Write down the business invariant

Consider a purchase request that moves from pending to approved. The invariant is that the request produces one approval record and moves forward exactly once. A successful click or a visible confirmation can be evidence of progress, but the invariant describes the result the business depends on.

Give the starting state a clear name and record what has to be true before the event. Identify the actor, the action and the observable result. This makes it possible to express the same scenario in a service test and in a smaller set of end-to-end journeys.

Exercise the transition under pressure

Start with a valid pending request. Submit an approval with a stable request identifier, then simulate delivery of the same command again. Check the final request state and count the approval records. If the contract permits an idempotent response or a duplicate rejection, assert the behavior the contract specifies and confirm that the second delivery causes no additional effect.

Add a separate case for an actor who lacks approval permission. Verify both the response and the preserved pending state. A failure in authorization and a failure in the state transition now point to different checks.

Keep the evidence close to the result

Give each scenario a stable identifier and record the request reference, input variation and observed outcome. Use isolated test data so concurrent runs can distinguish their records. If an effect appears asynchronously, poll the observable condition with a bounded deadline and report the last state on failure.

Use browser tests to cover the journeys where user interaction matters. Put a broader matrix of retries, invalid states and permissions closer to the interface that owns those rules. That division keeps the browser suite useful for release decisions and makes a failed check easier to investigate.