Test oracles: how you know it’s right
An oracle is whatever tells you the output was correct. For most of testing history that was a hardcoded expected value. AI features have no such value — the answer is different every run — so the oracle problem went from theory to the central practical question of the job.
A test oracle is the source of truth you compare an output against, so you can say a result is correct rather than merely plausible. Every test has one, even when nobody has named it.
The oracle problem is the name for what happens when no such source exists. You can see the output and you have no dependable way to decide whether it is right. That used to be a niche academic phrase, and AI features have made it an everyday one.
Here is what it looks like when a team has not noticed the gap.
A junior tester once asked a question that stopped a room.
The team was testing a currency converter. Somebody typed 100 dollars, the screen said 78 pounds, and everybody nodded. Then she asked: "How do we know 78 is right?"
Nobody could answer. The number looked plausible. It came out of the system they were testing, so agreeing with it proved nothing. Somebody eventually opened a bank website, and the real answer was 74.
The thing they were missing has a name. It is called a test oracle, and it is the source of truth you compare an answer against.
The terms you will hear
- Test oracle. Whatever tells you the output was correct: a spec, a value, a rule, a person.
- Expected result. The specific value you compare against. The oracle is where that value came from.
- Oracle problem. Having no reliable source of truth for the output you are looking at.
- Partial oracle. A source that can rule some answers out without confirming the right one, such as "the total must equal the sum of the lines".
- Consistency oracle. Comparing against a previous run or another implementation. Useful for spotting change, and it proves nothing about correctness on its own.
Five oracles you already use
You use these daily without naming them, and naming them makes gaps visible.
- A stated expected value. The acceptance criteria say refunds take 14 days, so 14 is correct. Turning a story into cases is where that value comes from.
- A known-good source. A bank rate, a tax table, the previous release's output, a supplier's price list.
- A second implementation. Work the sum out yourself, in a spreadsheet or a script, and compare.
- A rule that must hold. The parts must sum to the total. A refund can never exceed what was paid. Nobody sees another customer's data.
- A person who knows. Sometimes the only oracle is the finance lead, and asking is faster than deducing.
Why this matters more every year
For most of software history, oracles were easy. A spec said what to expect and you compared. That is why the idea sounds academic.
Then features started producing answers nobody can look up. A recommendation. A summary. A support reply written by a model. Ask what the correct output is and there is no single right answer, which means there is no value to compare against.
That is the whole reason assertions break on AI features. The old oracle disappeared, and the replacement is a set of properties that must hold plus a scored judgement. The idea in this topic is the foundation the entire AI testing layer sits on.
How to use it deliberately
- Before writing a test, say where the expected result comes from. Out loud. If the answer is "it looks right", stop and go and find a real source.
- Never let the system be its own oracle. Refreshing a snapshot until the test passes is the same error in a nicer wrapper.
- Prefer a rule when a value is unavailable. For example: the sum of the line items plus delivery must equal the total charged, whatever those numbers happen to be.
- Write the oracle into the test case. One line saying where the expectation came from turns future arguments into a lookup. It belongs next to the expected result in a case somebody else can run.
- Ask who owns the answer. For money, tax, medical or legal outputs, the oracle is a person or a document, and you want their name on it.
- Where nothing exists, say so. "There is no source of truth for this output" is a genuine finding, and it usually reveals a requirement nobody wrote.
If you cannot say where your expected result came from, you are not testing. You are agreeing with the software.
A worked example
Here is the same currency screen tested with the oracle named in every row. It takes a few extra seconds per case and it changes what the suite proves.
FEATURE currency converter on the checkout page
CHECK EXPECTED ORACLE (where it came from)
100 USD to GBP 74.00 ECB daily rate, fetched
separately, 2026-08-22
rate shown matches the rate same value the rate our own pricing
used in the charge service returned, compared
to what the customer paid
converted total + delivery rule: parts must equal the
= amount charged exact match total. no external source
needed
unsupported currency (JPY) clear error, acceptance criteria WB-1902
no conversion
rate older than 24 hours warning shown policy doc, finance, agreed
with Anita on 2026-07-14
rounding: 0.005 cases rounds up finance rule, written into
the ticket after we asked
WHAT WE FOUND BY NAMING THE ORACLES
two of the six had no source at all. Nobody had decided what should
happen with a stale rate or with a half-penny. Both became tickets
before any code was tested.The last block is the point. Naming the oracle found two missing requirements, and no amount of clicking would have surfaced them. That is testing before the test.
How to show you know it
- An oracle column in your cases. Rare, cheap, and it makes reviewers trust the suite.
- A missing oracle you turned into a requirement. The strongest version of this skill. "Nobody had decided what a stale rate should do."
- A property test where no value existed. Showing you can assert that parts sum to a total, when the total itself varies, is exactly what AI features need.
- A refused snapshot. "I did not update the stored output to match, because that would make the system its own oracle." Say that once and people remember it.
Questions
Is an oracle just the expected result?
The expected result is the value. The oracle is where that value came from. Two testers can write the same expected result, and only one of them can tell you why it is correct.
What if there genuinely is no source of truth?
Then you test properties and ranges instead of values, and you record that no exact oracle exists. That is honest and useful. It is also the normal situation for anything a model generates.
Are snapshot tests bad then?
They are useful for noticing change and useless for proving correctness. Keep them for detecting drift, and make sure something else establishes that the first snapshot was ever right.
Who should own the oracle for money or legal outputs?
A named person outside the engineering team, usually finance, legal or product. Get the rule written down. It protects everybody, including them.