Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Learn the Fundamentals  ›  Lesson

Test Oracles — Knowing the Right Answer

Test Oracles 12 minA test oracle is any trusted source that tells you what the correct result should be, so you can decide whether a test passed.

Test Oracles — Knowing the Right Answer

You apply SAVE10 to a Basketly cart worth ₹600 and the total shows ₹540. Pass or fail? You can only answer because you know the rule: 10% off carts of ₹500 or more. Take the rule away and the screen tells you nothing. Whatever tells you the right answer is called an oracle.

The rule

No expected result, no test: an oracle says what is right.

A test oracle is any trusted source you use to decide whether an actual result is correct. Running software is easy; judging it is the hard part, and the oracle is what makes the judgement possible.

Common oracles, with a Basketly example for each:

Oracle Basketly example
Specification The story says SAVE10 gives 10% off from ₹500
Calculation ₹600 × 0.9 = ₹540, worked out by hand
Previous version The old checkout showed the same total for the same cart
Comparable product Other grocery apps round to the nearest paisa the same way
Consistency Prices in search match prices in the cart
Human judgement The product owner looks and says "yes, that's what I meant"

No oracle is perfect. A specification can be wrong, an old version can have the same bug, and a human can misremember. Good testers use more than one oracle for anything important, and notice when two oracles disagree, which is often where the bug lives.

The shortcut

Before running any test, finish this sentence out loud: "I expect ___, because ___." The first blank is the expected result; the second blank is your oracle. If you cannot fill the second blank, you are exploring, not testing yet.

Testing SAVE10 on a ₹480 cartStep 1 of 4
  1. Fill the first blank

    "I expect no discount, so the total stays ₹480..."

The trap is judging by "looks fine". A total of ₹432 looks perfectly reasonable on screen; only an oracle reveals it is wrong.

Drills

Answer fast — trust the rule.

quick drill

What is a test oracle?

quick drill

You check that a product's price in search matches its price in the cart. Which oracle is that?

quick drill

The spec says delivery is free above ₹300, but the product owner says ₹350. What should you do?

quick drill

Why is "the old version did the same thing" a weak oracle on its own?

quick drill

A tester cannot finish "I expect ___, because ___" for a new screen. What are they doing?

Remember

  • No expected result, no test: an oracle says what is right.
  • Say "I expect ___, because ___" before every check.
  • Oracles can be wrong; when two disagree, raise it.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhere does the right answer come from?

Basketly adds a new 'reorder last basket' button. There is no written specification yet. Name two oracles you could use to decide whether the button works, and explain the weakness of each.