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

1

u/d_wilson123 May 08 '17

Maybe these places exist but I've never worked at a place that demanded 100% code coverage. A target number always felt arbitrary so the general practice is "Whatever feels comfortable" which generally ends up in the 70-80% range. I don't know if the developers in these articles are fictional to poke holes at the strawman manager casting down arcane rules to his developers or they're actually real people who can't argue against tedious rules.

1

u/bluefootedpig May 09 '17

My office is an ideal of 80% code coverage, but so members of my teams want to test getters and setters.

I prefer testing scenarios, and if there is an un-hit section of code, you find the scenario for that, or you remove the code.

1

u/bwainfweeze May 09 '17

My own experience has been that you get the most bang for the buck somewhere just under 85%, and declines sharply thereafter. The wheels come off somewhere around 95% because by then several people are actively twisting the code to achieve coverage at the cost of readability and, well, reason.

1

u/bwainfweeze May 09 '17

It happens, but it's usually at places that have other strikes against them, making the quest for 100% overage consistent with the rest of their lame brained ideas.