Is Test Coverage a Good Metric for Test or Code Quality?
Let the flame wars begin.I bet a pilot doesn’t look at half of this stuff.Firstly, definitions.As with all good opinion pieces, I’ll be clear about the terms I’m using and what they mean.Code Coverage PercentageThe lines in the code that are executed when one of the automated tests run, expressed as a percentage of the entire codebase. For example, 65% code coverage would mean that the tests execute 65% of the code.“Good Metric”For a metric to be “good” in this context, it must have some kind of relationship with code that is higher quality. Quality is defined as easier to understand, change and maintain.So what does a high code coverage percentage tell us?Consider the following example code, freakishly simple. It takes a value and gives the output of a map. The map is hard coded for (...)