-cov LOC is inadequate for 1 liner branching; need a metric based on branching

Walter Bright newshound2 at digitalmars.com
Mon Feb 12 00:58:48 UTC 2018


On 2/11/2018 3:01 PM, Timothee Cour wrote:
> It's about `line coverage` vs `branch coverage` (see exact definition
> in linked article),

Ok, I see now, thanks for your patience and the clarification.


> that difference is very large in practice.

Only if one cares about the percentage metric. Pragmatically, I'm much more 
interested in exactly what was not covered rather than the percentage, and any 
good QA department should be focused on that rather than the percent metric.

BTW, when I wrote the -cov implementation, I threw in the % metric just for fun <g>.


> What's more, code instrumentation to enable branch coverage is not
> more complex to implement compared to line coverage (I would even
> venture it's less complex and less costly).

I'm not convinced of that, as you've still got the:

    if (a) b;

problem. Furthermore, in the first link they alluded to the thrown exception 
problem, with some gobbledy-gook answer on how they dealt with it (they punted). 
Sequence point coverage doesn't have that problem.

Next, in the python linked example, they found it necessary to add a bunch of 
pragma's to give needed information to the branch counter. I have a hard time 
seeing anyone using that unless they're forced to by management. The idea with 
dmd's coverage is you type -cov and you get a coverage report. Done.

The coverage report is a simple text file that is both readable by itself and 
trivially parse-able with a program for those who really want a GUI presentation 
of the results, or who want to integrate it with github (as has been done for 
us, yay!).

(Back in the olden daze, a coverage analyzer was a separate product that came 
with a 200 page manual. Who bought it? Managers. Who used it? Nobody. You'd see 
the manual on programmers' shelves, still in its shrink wrap.)

---

I'm actually glad to see people complain about -cov and want to improve it. It 
shows it is successful - people are using it! As Bjarne Stroustrup once said, 
there are two kinds of products - ones people complain about, and ones people 
don't use.


More information about the Digitalmars-d mailing list