Unit tests
Essence
A unit test verifies one unit of behaviour (a function, a type, a small module) in isolation from the outside world: no network, database, UI or timers. Dependencies are replaced with test doubles through protocols. The goal is to learn quickly and deterministically that a code change did not break expected behaviour. You test behaviour through the public contract, not every method in turn: tests written against the implementation break on every refactor.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep