by belval · 4y ago · 0 comments
This absolute is somewhat misplaced in my experience. Yes hitting 100% code coverage does not inherently make the code better, but it does force people to look up the tests that were there before and it often helps with providing some form of context.
"Code coverage is only loosely correlated with code quality" would be my take.
The main takeaway is that if you test your code on the wrong ("unit") level, you may easily get ~100% coverage, but that is mostly worthless. Test on higher levels instead, ie. against business requirements, and don't worry about code coverage that much.
We've noticed that you can still have all sorts of problems in code that has 100% coverage. We started using a TLA+ like "environment" to automagically prove assertions about our code (mostly things like "there's only one path that gets you to this counter := counter + 1 line and there's a mutex around it.") It's a pain in the rear, but probably less of a pain in the rear than trying to prove that sort of thing with traditional tests and an exhortation that you have to have 100% coverage.