What are some code coverage tools for Perl?

后端 未结 4 1095
谎友^
谎友^ 2020-12-29 06:48

Are there any good (and preferably free) code coverage tools out there for Perl?

相关标签:
4条回答
  • 2020-12-29 06:55

    Yes, Devel::Cover is the way to go.

    If you develop a module, and use Module::Build to manage the installation, you even have a testcover target:

     perl Build.PL
     ./Build testcover
    

    That runs the whole test suite, and makes a combined coverage report in nice HTML, where you can browse through your modules and watch their coverage.

    0 讨论(0)
  • 2020-12-29 07:10

    Moritz discusses how modules built with Module::Build can use Devel::Cover easily.

    For modules using ExtUtils::MakeMaker, an extension module exists to invoke the same functionality. Adding the following code before the call to WriteMakefile():

    eval "use ExtUtils::MakeMaker::Coverage";
    if( !$@ ) {
        print "Adding testcover target\n";
    }
    

    ... will allow one to run the command 'make testcover' and have Devel::Cover perform its magic.

    0 讨论(0)
  • 2020-12-29 07:14

    As noted, Devel::Cover is your friend, but you'll want to google for it, too. It's documentation is a bit sparse and if you change your environment radically, you'll need to reinstall it because it builds Devel::Cover::Inc with a bunch of information pulled from your environment at the time you install it. This has caused plenty of problems for us at work as we have a shared CPAN environment and if one developer installs Devel::Cover and a different developer tries to run it, strange (and incorrect) results are common.

    If you use this module, also check out Devel::CoverX::Covered. This module will capture much of the information which Devel::Cover throws away. It's very handy.

    0 讨论(0)
  • 2020-12-29 07:20

    As usual, CPAN is your friend: Have a look at Devel::Cover

    0 讨论(0)
提交回复
热议问题