Coverage Analysis

An advanced feature of Dynamic Debuggers.

While executing application the debugger collects information which source commands were exected (files, lines). After the run this is used to display which paths of the application have been covered by the run and which not.

This is especially useful when writing a testsuite, as execution of the testsuite allows the developer to determine if all parts of the tested application or package have been exercised by the tests.

This is related to Hotspot Analysis. The latter is an extension of this analysis, by not only remembering which lines were executed, but also how often.


has this type of analysis ever been done on the tcl and tk source distributions, to determine how much of the code is being tested by the test suites?


KBK - In what sense do you mean that question? If you're asking whether coverage analysis is available for Tcl scripts, the answer is yes: Tcl Dev Kit, among others, offers it. If you're asking whether coverage analysis has been done on Tcl/Tk's own source code, I'm not sure about the answer. The maintainers don't do it routinely, as far as I know. I tried running PureCoverage on Tcl/Tk with the test suite a few years ago, and the coverage was quite good.

Coverage analysis is only a guide. It's not wise to obsess about it as Dilbert's boss sometimes does. Insisting upon 100% test coverage is contrary to "defensive programming", where it's common to put in code to report, if not handle, "impossible" cases.


MAKR - This topic catched my eye at least two time in the last few months on comp.lang.tcl. So from the most recent thread I collected the following links:

  • Uwe Klein wrote that with some little effort BLT's bltdebug or Tclx' cmdtrace could be used, his mail at Google [L1 ]
  • Arjen Markus did a simple coverage analyser, which can be found here [L2 ]
  • Last but not least Nagelfar was mentioned by its author Peter Spjuth to be able to do the analysis