# Retries and idempotency in software testing

> See why a successful operation can be retried and which effects to inspect after duplicate delivery. Test that a reward event creates one voucher.

Source: https://cueapril.com/knowledge/explanations/retries-and-idempotency
Updated: 2026-12-02
Index: https://cueapril.com/llms.txt

## What should a test check when the same operation can be retried?

Check the lasting effect of repeating the same logical request. Where the contract promises idempotency, a retry should leave the business outcome equivalent to one successful attempt. Inspect the recorded state and any promised side effects after both attempts.

## Why might a successful operation be repeated?

A service can commit a change before its caller receives the acknowledgement. The caller sees a timeout and tries again. A queue can also deliver the same message twice. Use the contract’s definition of a duplicate, including the identity of the request and any expiry period.

## Which result should the test inspect?

Read back the business record and count the promised effects, such as allocated seats or issued vouchers. An initial request and a replay can legitimately have different response details. The contract determines which effects and response guarantees must stay consistent.

## Worked example: Two acknowledgements, one voucher

Process one reward event, then deliver it again using the same event ID. Check that a fresh read finds one voucher for that event and that the member’s reward balance was reduced once. A test that stops at the handler’s second acknowledgement would miss a duplicate voucher.

## 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

- [Idempotency](https://cueapril.com/knowledge/definitions/idempotency)

- [How to test a state transition](https://cueapril.com/knowledge/how-to/test-state-transitions)

- [How to verify a consumer-driven contract](https://cueapril.com/knowledge/how-to/verify-a-consumer-contract)

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