test.fake_unused
A test passed otherwise, but its fakes: scripted more answers for a provider operation than the code called it for.
Area 13, Testing; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
A test never reaches a real provider. fakes: scripts the answers an
operation gives, in order, and each answer stands for a call the test
expects the code to make. An answer left over means the code made fewer
calls than the test says, so either the test is wrong about the code, or
the code no longer does what the test was written for. Either way the
test would pass without proving what it claims.
What it looks like
domains/shipping/actions/book.test.jadpo, testing book, which books a
collection through the couriers connection:
use app { couriers }use shipping/failures { SlotGone }test "a taken slot is the app's own failure" { fakes: { couriers.bookings.create: [slot_taken, unavailable] } assert book("N1 9GU") fails SlotGone}
FAIL a taken slot is the app's own failure --> domains/shipping/actions/book.test.jadpo:6 fake: `couriers.bookings.create` was called once, and its `fakes:` scripts 2 answers reason: Each scripted answer is for a call the test expects, so one left over means the code calls the operation less often than the test says. next: Remove the answers no call takes, or find why the code doesn't call `couriers.bookings.create` (agent) rule: test.fake_unused rerun: jadpo test domains/shipping/actions/book.test.jadpo:6 --seed 1test failed: 1 failed, 1 action test
(agent) at the end of the next: line means your coding agent can make
the fix itself.
How to fix it
Here book maps slot_taken to SlotGone at the first call, so nothing
calls couriers.bookings.create a second time to take unavailable.
If the code is right to call it once, script one answer. In
domains/shipping/actions/book.test.jadpo:
couriers.bookings.create: [slot_taken]The test scripts the one call book makes, and passes.
If the test meant a provider that is down first, put unavailable
first. A call answered unavailable is tried again, so the second
answer is taken too:
test "a taken slot is the app's own failure, after a retry" { couriers.bookings.create: [unavailable, slot_taken] ...}
The test now proves that book retries an unavailable courier and still
fails with SlotGone when the slot is taken.
Related
Markdown for agents: /docs/errors/test.fake_unused.md.Built from Jadpo main at aee2e8f.