Skip to end of metadata
Go to start of metadata

Devel::Cover

Description

Coverage Test via Module::Build

Module::Build

Icon

If you are using Module::Build you can utilize Devel::Cover easily as part of your build process.

Module::Build can do test coverage using Devel::Cover. Devel::Cover takes a lot of options, which can be really interesting when customizing your coverage test.

In order to pass in options you have to utilize the environment variable: DEVEL_COVER_OPTIONS.

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 ():

Coverage Database

Icon

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.

Other Uses

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

From Blog

Icon

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)

I have lately turned my interest towards C and Objective-C in particular, looking into iPhone application development.

In my continued quest to get my tools box filled I am monitoring some interesting mailing lists to pick up stuff as it appears.

The other day somebody write to the official Apple Xcode list inquiring about using gcov and generating HTML data. My brain started spinning, I felt like I had read something about this on CPAN.

After a quick search on search.cpan.org I located: gcov2perl a part of the Devel::Cover distribution.

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...

helloworld.c

I skimmed a tutorial on gcov to see how it would normally work.

Compile with options of using gcov:

Run the executable produced:

Turned to 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:

The 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.

Have fun covering your C code and presenting in using a very nice Perl tool.

See Also

Resources