Mock Object

Noun · Development

Definitions

  1. A test double that simulates the interface of a real dependency — such as a database client or HTTP service — and records the calls made against it so that a unit test can verify both the return behavior and the interaction pattern without touching real infrastructure.

    In plain English: A fake version of a real component used in testing that lets you check your code called it correctly without actually connecting to the real thing.

    Example: "The mock object for the payment gateway verified we called `charge()` exactly once with the correct amount before returning a fake receipt."

Related Terms