Re: Code coverage tool
On Feb 4, 7:22 pm, Ian Collins <ian-n...@hotmail.com> wrote:
Gerhard Fiedler wrote:
On 2008-02-04 06:55:35, Ian Collins wrote:
ev wrote:
We are looking for any testing tool that is capable of
checking code coverage for C,C ++ and Java code. Or at
least for C and C++. We want to know how much (percentage)
of our code written on C/C++ is covered in terms of
function calls and line calls. We tried Rational
PureCoverage. It's excellent but has some limitations in
our case. Any idea would be greatly appreciated.
Write the tests first, that way nothing gets written that
isn't tested.
How do you know whether every branch/condition in a function
gets executed when you run the tests that you wrote
(independently of whether you wrote them before or after you
wrote the function)?
My contention is *when* you write the tests is important, you
can only get full coverage without tools when they are written
first. The only production code that gets written is written
to pass tests.
This was, there will not be a branch unless it was required to
pass a test.
Which still doesn't begin to guarantee anything like full
coverage. Given a function which can be called with two
independent conditions, you still can easily end up with tests
that don't test all four combinations of the conditions. Not to
mention tests that never test the "exceptional" paths, e.g. when
new throws bad_alloc, etc.
There is no silver bullet, and writing the tests before writing
the code really doesn't buy you anything in general.
--
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