# Testing asynchronous background jobs

> Test a background job against an observable completion condition. Cover retries and duplicate delivery while keeping arbitrary waits out of the suite.

Source: https://cueapril.com/guides/test-asynchronous-jobs
Updated: 2026-12-01
Index: https://cueapril.com/llms.txt

## How can we check completion and retries when processing finishes after the request returns?

Observe a durable state transition or event rather than sleeping for an assumed processing time. Give the test control over when the worker runs and when an acknowledgement arrives.

An order message is processed, then its acknowledgement is lost.

## Work through the decision

When delivery repeats, a naive worker creates a second order. A fast happy-path assertion sees only the first one.

Steps and evidence for the reviewer

| Step | Evidence to keep |
| --- | --- |
| Enqueue once | Capture the business request key. |
| Replay delivery | Keep the business key and change the delivery ID. |
| Check terminal state | Assert one stored order and the expected completion event. |

## What changes the decision

Keep timeout and duplicate tests separate. A job can finish on time and still perform the business action twice.

## Primary documentation

- [Cue April’s original sample test report](/sample-report)

By Cue April. Updated 2026-12-01.

## Related

- [Testing guides](https://cueapril.com/guides): Learn how to select regression checks, verify generated tests and read failure evidence. Use examples that connect a code change to user behaviour.
- [Worked test reports](https://cueapril.com/reports/retry-duplicates-order): Read a local test report for a checkout request delivered twice. Compare the resulting order count and verify the business request keeps its identity.
- [Pull request testing](https://cueapril.com/use-cases/pull-request-testing): See what a pull request test report should show before you merge. Follow a failing checkout check through the fix and inspect a real PR report.
