# How to choose a test oracle

> Choose an independent test oracle from a business rule, approved example or invariant. Use a parcel-packing case to see where an expected result comes from.

Source: https://cueapril.com/knowledge/how-to/select-a-test-oracle
Updated: 2026-12-02
Index: https://cueapril.com/llms.txt

## How can I decide what the expected result of a test should be?

Look for an expectation independent of the code under test. A reviewed business example, an invariant or a documented relationship between results can all serve as a test oracle. Record where the expectation came from and what it lets you infer.

## Find a defensible expectation

Choose an oracle that would disagree with at least one plausible wrong result.

1. Ask for the applicable rule, version and units. Work one example by hand with the person responsible for the behaviour.
2. If the full output is difficult to calculate, identify a property that must hold or an independent reference with known limits.
3. Keep the expectation with its source. If you have only historical output, label the check as characterisation and flag the question of correctness for review.

## Worked example: How many parcels should be created?

The packing rule allows up to six identical items in each parcel and asks for the fewest parcels. For thirteen items the warehouse owner agrees on three parcels. The test can count the parcels and check that every item is present exactly once. Calling the production packing function to calculate the expected count would hide an error shared by both calculations.

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

- [Agree what a correct result looks like](https://cueapril.com/knowledge/playbook/agree-expected-behaviour)

- [What a characterisation test can tell you](https://cueapril.com/knowledge/explanations/characterisation-and-correctness)

- [Metamorphic testing explained with a worked example](https://cueapril.com/knowledge/explanations/metamorphic-testing-explained)

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