Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tests

Your tests are either fast or honest. Real in-memory implementations are both. Mocks are neither.

Article: Tests

Every test mocked find_by_email to return None, because that is what the assertion needed. The unique constraint fired in production. The mock did exactly what it was told; that is the problem. A MemDatabase that enforces the same constraints in a HashMap is fast, honest, and useful outside the test suite.

Two rules: generated mocks, and tests skipped without a reason.