Why Good Developers Write Bad Unit Tests

Go crazy with long test names
Which of the following function names would you prefer to see in production code?
userExistsAndTheirAccountIsInGoodStandingWithAllBillsPaid

isAccountActive

The first conveys more information but imposes the burden of a 57-character name. Most developers are willing to sacrifice a bit of precision in favor of for a concise, almost-as-good name like isAccountActive (except for Java developers, for whom both names are offensively terse).

For test functions, there’s a crucial factor that changes the equation: you never write calls to test functions. A developer types out a test name exactly once – in the function signature. Given this, brevity still matters, but it matters less than in production code.

Whenever a test breaks, the test name is the first thing you see, so it should communicate as much as possible. For example, consider this production class:

https://mtlynch.io/good-developers-bad-tests/