Coverage Test via Module::Build
If you are using Module::Build you can utilize Devel::Cover easily as part of your build process.
In order to pass in options you have to utilize the environment variable:
In order to execute a coverage test you could do the following:
After this you will have a coverage report in
cover_db/coverage.html. The report might be very extensive, providing coverage information on externals components you include via Subversion externals or if you are using larger frameworks like Mojolicious. You can then provide options to Devel::Cover to customize your report.
Here are the options Devel::Cover currently support ():
Please note that when experimenting the options, it is very important that you clear the existing coverage database to see the result. You might get a report based on the previous run of you have only changed some of the options.
When experimenting with the options, prefix the invocating line with the note mentioned above.
Outputting Coverage Reports as Part of Your Continuous Integration
Devel::Cover can output beautiful graphical HTML formatter reports, which allow you to click down through the report in order to get more information on your current coverage. This can be integrated into your Continuous Integration process, if you are using Jenkins. This mean the Devel::Cover generated reports are integrated with the other reports generated by Devel::Cover in the in the Jenkins user interface.
Please see the article on Continuous Integration.
Formatting gcov files using Devel::Cover
The follow article is taken from a blog entry I wrote some time ago. It has been integrated here so it can be improved and put into a context where it can refer to other resources in the Wiki and it can be referred more easily. (original)
In my continued quest to get my tools box filled I am monitoring some interesting mailing lists to pick up stuff as it appears.
I have been a long time fan of Devel::Cover, having worked as a Perl programmer for many years, so I was happy to see that this particular tool might scratch this itch.
So I threw together your normal hello world example...
I skimmed a tutorial on
gcov to see how it would normally work.
Compile with options of using
Run the executable produced:
gcov2perl and followed the manual here (changed to reflect my own example):
Creates a single gcov file in our case:
Transform data to Devel::Cover’s format:
Create the report:
Open the report in your browser (the OSX way):
And by clicking the filename you get this report:
helloworld.c example is very simple, but it proves a point - that it actually works.
I am only scratching the surface of what can be done and I have not fallen into any pitfalls - everything worked fine and looks good, but I am sure it can become more difficult.