←back to thread

873 points belter | 1 comments | | HN request time: 0.469s | source
Show context
er4hn ◴[] No.42952089[source]

> Code coverage has absolutely nothing to do with code quality (in many cases, it's inversely proportional)

I think this one keeps on being viewed as a % metric. You have 50% code coverage, 75%, 99.9%, 100%, etc. In that sense it is useless. Where I think code coverage has an enormous value is in showing what parts of your logic are/are not covered by test code. Being able to eyeball that and see where key parts of logic are not tested is extremely helpful and tends to get lost in these discussions.

replies(1): >>42958181 #
1. Izkata ◴[] No.42958181[source]

> Being able to eyeball that and see where key parts of logic are not tested is extremely helpful and tends to get lost in these discussions.

I've been saying for years code coverage broadly is fine, we're just presenting the metric in a screwed up way that makes people focus on the wrong thing. It should be absolute value and flipped, presented similar to linting: instead of percent of covered lines, it should be raw count of uncovered lines.

Not only does this help you focus on "this code has no tests" instead of "number go up", it removes the painful edge case where refactoring covered code to be shorter makes the percent-based metric worse.