perlunit-testingjenkinscode-coverageclover

Test Coverage in Jenkins for a Perl application


I just implemented an excellent example of test coverage in Perl described at Perl, Code Coverage Example

But that required Module::Build , Now what if i have existing Perl Application which does NOT have the Module::Build instrumentation, is there a way to get test coverage for unit or functional tests ?

I looked at :

Clean up from previous test run (optional)
  cover -delete

  #Test run with coverage instrumentation
  PERL5OPT=-MDevel::Cover prove -r t

  #Collect covered and caller information
  #  Run this _before_ running "cover"
  #  Don't run with Devel::Cover enabled
  covered runs
    - or e.g. -
  covered runs --rex_skip_test_file='/your-prove-file.pl$/' \
          --rex_skip_source_file='{app_cpan_deps/}'

  #Post process to generate covered database
  cover -report Html_basic


  %perl -d:Coverage -Iblib/lib test.pl

But this seems to indicate Code Coverage while running the application.

I want to be able to get a Clover or Cobertura Compatible output, so i can integrate it with email-ext in Jenkins


Solution

  • Task::Jenkins may be of some help. It has instructions about how to publish the Devel::Cover HTML reports through Jenkins, as well as info about adapting other Perl tools to Jenkins.

    Jira has some instructions about integrating Devel::Cover into Jenkins.

    To get code coverage for any Perl process (test, application, server, whatever) you set the PERL5OPT environment variable to -MDevel::Cover which is like putting use Devel::Cover in the program. If your command to execute tests is perl something_test then you'd run PERL5OPT=-MDevel::Cover perl something_test.

    If you're using prove, use HARNESS_PERL_SWITCHES=-MDevel::Cover prove <normal prove arguments>. This tells prove to load Devel::Cover when running the tests, but avoids gathering coverage for prove itself.