Most established languages have solid test coverage tools available for them, but the depth of functionality differs significantly from one to another.
Also, all the various VMs and compilers have such heterogeneous structure that writing a code coverage tool must be a very different job in C than in Lisp, for example.
- Python has
sys.settrace
to tell you directly which lines are executing - Clover (for Java) uses its own compiler and adds debug metadata (last time I used it, anyway)
- Emma (for Java) has a ClassLoader which re-writes bytecode on the fly
- COVER (for Lisp) has an annotation pass to instrument the code
I'm interested in the implementation of code coverage for different languages:
What are the main approaches to get to C0 coverage, where you can track which lines of code have been executed? I mention native VM introspection and static and dynamic code instrumentation above - are there other methods?
Getting to more enlightened coverage data, like C1 or C2, seems like a language agnostic task compared with C0. Is smacks of big Karnaugh map manipulation to me; are there best practices on how to actually do it? Do more modern logic techniques like fuzziness play a role?
A much overlooked aspect of test coverage is displaying the results back to the programmer, which gets increasingly hard with C1 and C2 data. Frankly, although they get the job done for C0, I'm underwhelmed by most test coverage interfaces; what novel and intuitive interfaces have you seen for coverage data?