Re: Code coverage tool
On Feb 6, 1:26 am, REH <spamj...@stny.rr.com> wrote:
On Feb 5, 5:55 am, James Kanze <james.ka...@gmail.com> wrote:
[...]
With regards to coverage tools:
If you have a function along the lines:
void
f( bool c1, bool c2 )
{
if ( c1 ) {
x ;
} else {
y ;
}
if ( c2 ) {
z ;
} else {
u ;
}
}
The coverage tools I analysed back then would report 100%
coverage if you called the function twice, once with
f(true, true) and once with f(false, false), for example.
Which, of course, is completely wrong. Other cases which were
missed were things like never testing the case where a loop
executed 0 times. Not to speak of exceptions. My conclusion at
the time was that they were worthless; we needed good code
review, including review of the tests.
Hopefully, the situation has improved since then.
It depends on the type of coverage you are interested in. For full
path coverage, your tool would be wrong (and sometimes it's an
impossible thing to ask for).
100% full path coverage probably isn't always possible. But if
a tool reports path coverage, it should be as a per cent of path
coverage.
If you are only look for statement coverage (or even MCDC),
you tool is correct.
And what use is statement coverage? What does knowing that your
tests have exercised 95% of the statements in the code buy you?
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34