3 ms·
The thing with unit tests is that they test units. A unit of code might be a simple algorithm inside one function but more often than not the unit is a more com
by yason 15y ago
The thing with unit tests is that they test units. A unit of code might be a simple algorithm inside one function but more often than not the unit is a more complex interaction that is better covered by a smart test on a whole lot higher level.
I prefer fewer tests that try to touch most of the essential features in one go, rather than several low-level tests that test simple if not idiotically limited cases. I prefer fewer tests and high code coverage: by being smart you can do a lot of testing even with a single test if only it touches the strategically most sensitive parts of your program.
Also, most low-level stuff you will test implicitly by the rest of your code. Lots of your higher level stuff would fail to work if your lower level functionality was crappy. Thus, the basic utilities tend to straighten themselves (bug-wise) early on.
Lines of code have a cost and lots of tests drive up your lines. Less code, smarter code. Less tests, smarter tests.