Back to the glossary
Test levels and methods
Test oracle
A test oracle is the source used to determine a test’s expected result, such as a specification, a reference system, a model or an expert’s domain knowledge.
Also known as: oracle, expected result, reference result
How does the test know what is right?
Running a test is usually easy. The harder question is which result would be correct. That is what the test oracle provides. Without an oracle, a test can only tell that “something” happened, not whether it was the right thing.
Typical oracles
- Specification: the requirement states the expected value directly
- Reference implementation: an older or simpler system computes the same thing
- Model: a plant model or simulation predicts the behaviour
- Previous result: in snapshot or golden-file tests, the last released state serves as reference
- Plausibility rules: the result must be sorted, positive or within a tolerance, for example
The oracle problem
For complex calculations, AI components or noisy measurements there is often no exact expected result. Tolerance bands help, as do checking properties instead of fixed values (property-based testing) or comparing several independent oracles.