Perl Testing: A Developers Notebook

Validating Kwalitee

After all of the work coming up with the idea for your code, writing your code, and testing your code (or writing the tests and then writing the code), you may be ready to share your masterpiece with the world. You may feel understandably nervous; even though you know you have good tests, many other things could go wrong ”things you won't recognize until they do go wrong.

Fortunately, the Perl QA group has put together loose guidelines of code kwalitee based on hard-won experience about what makes installing and using software easy and what makes it difficult. The CPAN Testing Service, or CPANTS, currently defines code kwalitee in 17 ways; see http://cpants.dev.zsi.at/kwalitee.html for more information.


Note: Kwalitee isn't quite the same as quality, but it's pretty close and it's much easier to test .

Rather than walking through all 17 indicators by hand, why not automate the task?

How do I do that?

Download and install Test::Kwalitee . Then add the following code to your t/ directory as kwalitee.t :

#!perl eval { require Test::Kwalitee }; exit if $@; Test::Kwalitee->import( );

Then run the code with perl :

$ perl t/kwalitee.t 1..8 ok 1 - checking permissions ok 2 - looking for symlinks ok 3 - needs a Build.PL or Makefile.PL ok 4 - needs a MANIFEST ok 5 - needs a META.yml ok 6 - needs a README ok 7 - POD should have no errors ok 8 - code should declare all non-core prereqs

What just happened ?

The test file is very simple. Test::Kwalitee does all of its work behind the scenes. The eval and exit lines exist to prevent the tests from attempting to run and failing for users who do not have the module installed.

Test::Kwalitee judges the kwalitee of a distribution on eight metrics:

Категории