Test Oracles

A Test Oracle is a source of truth that tells you whether your test result is correct or not. It’s what you compare your program’s output against to decide if the test passed or failed.

Example in real life

  • Imagine you’re checking a math problem in class.

  • You solve 2 + 2.

  • The answer key (4) is your oracle – it tells you whether your answer is correct.

Example in software

  • You test a login feature.

  • Expected result: “User should see dashboard after correct username & password.”

  • The requirement/specification is the oracle.

Why its important?

  • Without an oracle, you can run tests but you won’t know if the result is right or wrong.

  • Oracles are what make tests meaningful.

Let’s use the ATM machine example:

  • You go to an ATM and withdraw ₹500.

  • The ATM gives you some money.

  • How do you know if it’s correct?

    • You check your account balance slip.

    • Or you know you had ₹2000 before, so you should have ₹1500 left now.

That account balance / expected outcome is your Test Oracle.
It tells you whether the ATM worked correctly.