2 ms·
The argument is that good code [...] requires fewer unit tests Great point, my mistake. Title and headline updated (was: Good code has few unit tests). I reall
by andreyf 17y ago
The argument is that good code [...] requires fewer unit tests
Great point, my mistake. Title and headline updated (was: Good code has few unit tests). I really wish it were "duh", but measuring code quality by "unit tests per line" [1] is frighteningly common, and seductive in its simplicity and intuition.
1. Not necessarily directly. It might be in the form of "I'll add more unit tests to improve this code" (unit tests either cover an interface or they don't; going in to 'add more unit tests' to 'improve' code means you didn't define a clear enough interface to begin with). Or "our open source project has more unit tests than another" (but I won't point fingers).
- nostrademons 17y agoBut "unit tests per line" is a good metric. Why? Because programmers (well, at least I) hate writing unit tests. If you have a high unit-tests-per-line ratio, then writing one fewer line of code will let you avoid writing several lines of unit tests. The easiest way to bump your unit-tests-per-line metric is to delete lines of code. That's a positive thing, in my book.