5.3. Flaky test

In many ways automated tests are a programmer’s best friend. Like our friends in real life, we should be able to trust our friends in the codebase—the tests that immediately alert us to the occasional mistakes we make. Sometimes, a friend might turn out to be not so trustworthy after all.[3] One of the worst test smells I can think of is the simple case of a test that’s constantly failing—and is considered normal.

3 For the record, obviously none of my friends are like that. (Just in case you’re reading this.)

There’s a difference between a test failing when you change something—that’s a good thing, as the test obviously noticed a change in something you’ve considered important enough to check—and a test that fails all the time. ...

Get Effective Unit Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.