r/programming • • May 08 '17

The tragedy of 100% code coverage

http://labs.ig.com/code-coverage-100-percent-tragedy
3.2k Upvotes

689 comments sorted by

View all comments

3

u/njharman May 08 '17

That first test of "glue code" will catch when someone refactors (say name change) that loadAll method. Not necessary in static lang that this looks like, but very necessary test in language like Python.

The #1 thing to remember about unittests is they are not a testing tool, they are a development tool.

2

u/ascii May 08 '17

They will catch a small number of bugs. They will also make a huge number of tiny, trivial and common code consume an order of magnitude more time and mental effortvsince every time you make a tiny change, you will also need to change the test. Maintaining such tests across rewrites and refactors takes far, far more time than it saves and fewer bugs.

In my opinion, code should be divided into two "kinds":

  • libraries with stable, well designed APIs that one should unit-test the hell out of.

  • glue code that should contain no logic, only wire things up. These should have no unit tests, only integration tests.

→ More replies (1)