-cov LOC is inadequate for 1 liner branching; need a metric based on branching
Walter Bright
newshound2 at digitalmars.com
Sun Feb 11 22:32:41 UTC 2018
On 2/11/2018 1:55 PM, Timothee Cour wrote:
> I think you're missing my main point: it's explained here
> https://www.ncover.com/support/docs/extras/code-coverage/understanding-branch-coverage
> but the gist is that line based coverage is over-counting:
> ```
> if(A)
> // 100 lines of code
> else
> // 1 line of code
> ```
> gives a line coverage of ~ 99% vs a branch coverage of ~50%
> (assuming `else` branch never covered in unittests)
>
> What matters as far as bugs are concerned is that 50% of cases are
> covered. Increasing the size of the `if(A)` branch increases line
> coverage (which is irrelevant) but not branch coverage.
I understand that point. The -cov coverage percentage is the line coverage, not
the sequence point coverage. (Hence it will never be greater than 100%, and it
will never underestimate the coverage. It would be more accurately termed an
"upper bound" on the coverage.)
And yes, that makes it fuzzy in proportion to how many lines contain multiple
sequence points. Eliminating that fuzziness does require a vast increase in the
complexity of the -cov implementation.
More information about the Digitalmars-d
mailing list