Code Coverage
Zurich -- 22nd May 2008
Paul Johnson
www.pjcj.net
About me
Developer / QA Specialist / Manager
In Switzerland for the last eight years
Currently working at UBS
Support
I support Manchester United
Support
And Southampton
Code Coverage
Tells you how much of your code you have tested
There are various coverage criteria
"Testing never proves the absence of faults, it only shows their presence." Edsger Dijkstra
Trying to cover more of the testing problem space
Code coverage metrics
Subroutine Coverage
Statement Coverage
Branch Coverage
Path Coverage
Condition Coverage
Documentation Coverage
Methodology
Make sure your tests all pass
Run your tests using your coverage tool
Check your coverage reports
Write additional tests for uncovered code
Or remove the code
Or rewrite it
When the tests have run
Only the beginning
Any serious drive for quality takes effort and resources
Quality is not guaranteed, merely improved
Don't rely on code coverage
Devel::Cover
Code coverage tool for Perl
Mostly designed cycling up the hill from Triemli to Uitikon
runops
Perl compiles code to an optree
runops function walks the optree and calls appropriate functions
Devel::Cover replaces the runops function and does evil things
Experimental code messes with the vtable to call different functions
Back to Reality
At the end, Devel::Cover walks the optree again, mapping the ops back to reality and associating the coverage data
Databases containing coverage data from different runs are merged
Finally a report outputs the data in a pretty web page
Or in any other format
Other Languages
Translates from other coverage tools into Devel::Cover's database format
Currently only gcov from gcc
Works nicely for combined Perl and C projects
Future
Implement Path Coverage
Mutation Coverage
Regular Expression Coverage
Fully buzzword compliant AJAXy GUI