Day 11 of 60 · Unit, integration, contract

Unit testing

The cheapest defects to fix are the ones the engineer who wrote them catches before lunch. Unit tests are the discipline of catching them at the keyboard, not at the dashboard.

ProblemLogic regressions and incorrect implementations.

How it works

Small, fast, isolated tests of pure functions and small modules. Run on every save and every PR. Foundation of the test pyramid.

What it catches

Logic errors in pure code. Catches ~30–40% of defects when paired with type checking. Diminishing returns past 70% line coverage.

Tools

Vitest · OSS Jest · OSS pytest · OSS JUnit / xUnit / NUnit · OSS

Verdict by project size

Small
Must
Medium
Must
Large
Must
Extra-large
Must

Cost

Project size Setup Maint / mo Tool / mo CI / run
Small <10k LOC 4h 4h $0 +1m
Medium 10–100k LOC 2d 20h $0 +3m
Large 100k–1M LOC 5d 80h $0 +8m
Extra-large >1M LOC 15d 300h $0 +20m
Setup = engineer-days to first useful run · Maint = engineer-hours / month at steady state · Tool = out-of-pocket $ / month · CI = minutes added (or saved) per pipeline run

Lifecycle & ownership

When in lifecycle
Code Test
Per pull request · Runs in CI on every PR; gates merge.
Who owns it
Developer
Authoring + the inner loop
Collaborates with: QA / Test Engineer

Reference implementations

Quick check

Where do unit tests show diminishing returns?

One question. Pick the best answer. Your streak is saved locally on this device.

Save the lesson

Download SVG ↓

Screenshot for a 1:1, drop it in Slack, or download the SVG.

thinkbridge THE VALIDATION ATLAS DAY 11 OF 60 UNIT, INTEGRATION, CONTRACT Unit testing The cheapest defects to fix are the ones the engineer whowrote them catches before lunch. Unit tests are thediscipline of catching them at the keyboard, not at thedashboard. FIVE-MINUTE LESSON · ONE QUICK-CHECK QUESTION There’s a new way there
All 60 days →