Praktisches & Grundsätzliches zur Informatik

Software Test Coverage (practical metrics), Testabdeckung messbar

Best Practices for Monitoring Test Coverage

One of the most difficult aspects of testing is answering the question how perfect the testsuite we use actually is. The very first question to answer is:


Which part of my code is not yet tested?


To get an answer we need practical metrics and corresponding code instrumentation.


Classical metrics are: Path Coverage is not useful at all because most programs contain looping statements (so that the number of possible paths may not even be finite).

The usual way to measure Branch as well as Statement coverage is to measure Block Coverage.

A Block in this sense is always a pair ( S,A ) such that

An atomic statement in this sense is a statement atomic in the source code language (usually one line of code if you program in C, C++, Java, or C#). Note: Conditional statements – if and switch – are not atomic and are always seen as at least two pairs ( S,A ).

In contrast to Path coverage, Block coverage will make sense and is the most precise information on code coverage you can hope to get.

For a practitioner however all these classical metrics have four serious problems:

So you see:

More practical metrics are needed.

And they really exist:

You see: Both of these metrics — often applied in parallel — produce really valuable information on how thoroughly your code was testet. I recommend them highly (and use them all the time).
Wissenswertes zu "Testabdeckung messbar, Software Test Coverage (practical metrics)" zusammengestellt durch Gebhard Greiter.
tags: Coverage1gegreit Block1gegreit Problem1gegreit