software-design/your-first-unit-test-catch-the-leap-year-bug-a-quick-check-misses.md

Your first unit test: catch the leap-year bug a quick check misses

Building software · 5 min read ·

A unit test is a tiny piece of code that checks another piece of code: you pick an input, write down the answer you expect, and let the computer compare.

Here a one-line leap-year function passes two quick checks and still gets 1900 wrong. Edit the function in the page, run four tests, and watch the failing one turn green.