Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Writing tests for a module

by Ovid (Cardinal)
on Jun 05, 2001 at 22:14 UTC ( #85922=perlquestion: print w/ replies, xml ) Need Help??
Ovid has asked for the wisdom of the Perl Monks concerning the following question:

Working on a proper distribution package for a module and was thinking about the tests that need to be written. I've pretty much stuck to standard modules for the module, but I've repeatedly seen new Monks say things like "We don't have [insert ubiquitous module name here] installed on our server. Is it overkill to write tests to see if they are there?

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Comment on Writing tests for a module
Re: Writing tests for a module
by bikeNomad (Priest) on Jun 05, 2001 at 22:21 UTC
    I don't bother checking in my modules, but it's reasonable to check in your Makefile.PL so they know when installing it (or CPAN.pm knows) that they need something else. I even check for standard modules. If you use ExtUtils::MakeMaker, just add a PREREQ_PM hash arg to the arguments to WriteMakefile. From Archive-Zip's Makefile.PL:

    WriteMakefile( #snip PREREQ_PM => { 'Compress::Zlib' => 1.06, 'Carp' => 0, 'File::Path' => 0, 'File::Find' => 0, 'File::Basename' => 0, }, #snip );

    If you have PREREQ_PM set, CPAN.pm will use it to load prerequisites. Also, the .PPD file (used by PPM) will have the dependency information, which will allow PPM to load the required modules.

    update: added explanation at end

Re: Writing tests for a module
by John M. Dlugosz (Monsignor) on Jun 05, 2001 at 23:16 UTC
    No less reasonable than handling tech support manually. For people unfamiliar with Perl (customers want to run the program, not learn the language), a simple checker works wonders. For a set of perl scripts used by developers for certain testing, I included a check_setup script as well that makes sure it can find everything and explains about paths etc.
Re: Writing tests for a module
by traveler (Parson) on Jun 06, 2001 at 01:08 UTC
    It would sure be nice if you'd set it up so that CPAN.pm's shell would install all needed modules when installing your new module. I've not investigated how to do that (no need, yet), but it is very handy when downloading new modules!
Re: Writing tests for a module
by Daddio (Chaplain) on Jun 06, 2001 at 01:42 UTC

    There are a couple of good scripts on the List of installed modules node, specifically one I tried from cianoz. Don't know if that helps or not, but that one does work.

    D a d d i o

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://85922]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2014-10-02 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls