What Unit Tests Are For

Unit tests are not for finding bugs.

Unit tests test components (units!) individually, so they can’t find problems that come up when two (or more!) components need to play nicely together. (We use end-to-end tests for that.)

Unit tests are for designing small software components. They specify how your component works and let you verify that.

Good unit tests support refactoring: They allow you to make changes that don’t affect a component’s observable behavior, and then quickly verify that you haven’t broken the observed behavior.

Bad unit tests are another story for another time.