[adelaide.pm] Creating a baseline for Devel::Cover

Mike Bruins bruins at hal9000.net.au
Wed Jun 30 21:21:07 PDT 2010


Hi Mongers,

I'm hoping for some pointers on a question relating to Devel::Cover -
http://search.cpan.org/dist/Devel-Cover/lib/Devel/Cover.pm

Say I am about to embark on adding/fixing unit tests, and I wish to
accurately measure the improvement in code coverage.
At the start I will need a baseline that shows the all the files (e.g.
scripts and modules) and the amount of coverage in each case.
The trick is to have the all perl files represented in the baseline, not
just those exercised by the unit tests.

Illustration:
Say I have 100 files, but my unit tests use 10 of these files.  Say the
coverage was reported at 50%.
True coverage would be about 5%, not the 50% reported (*). 

My thoughts so far:
On day one it is not practical to write unit tests for all the files,
but it might be possible to write a perl script to pre-load the cover_db
with knowledge that the files exist.

The overall process may look like the following:
1) cover --delete --silent
2) something_to_set_cover_db_baseline.pl
3) make test  HARNESS_PERL_SWITCHES=-MDevel::Cover
4) cover

Is there an easy way to tell Devel::Cover about a file ?
Perhaps there is an easier way to achieve the whole process?
Thoughts very welcome.

Cheers,

 - mike

* If all files were equal weight, not likely in real world.








More information about the Adelaide-pm mailing list