[tpm] testing; using eval to catch an error in a module

Michael Graham magog at the-wire.com
Sat Aug 29 12:14:50 PDT 2009


> I'm pretty sure I'm not doing it the "proper" way, but my Googling 
> hasn't yielded much yet. The most I've been able to gather so far is 
> that the "normal" way is to have a 't' directory and in there have a 
> 'test.pl' that 'make install' can call.

Well, it is true that "make test" will indeed run your module's test
suite.  But honestly, that's not the main reason to do things The
Right Way (tm) instead of the Hacky Handmade Way (tm).

The advantages to doing standard Perl testing are:

  * your tests will be easier to write
  
  * your tests will be more concise

  * your tests will be more maintainable

  * your tests will make sense to other people

  * you can do more sophisticated testing more quickly (e.g. with
    Test::Deep, Test::MockObject, etc.)

  * you can get Test coverage with Devel::Cover

  * you can make a web-based dashboard of your test results by
    running your tests automatically on an hourly schedule and
    importing them into Smolder.  
    
    Imagine setting off alarm bells right after you break
    your code, instead of discovering the problem three weeks later
    when you finally decide to run your test suite again!

To get started, check out the following docs:

 Test::Tutorial:
 http://search.cpan.org/~rgarcia/perl-5.10.0/lib/Test/Tutorial.pod

 prove
 http://search.cpan.org/~andya/Test-Harness-3.17/bin/prove

 Test::More:
 http://search.cpan.org/~mschwern/Test-Simple-0.92/lib/Test/More.pm




Michael



More information about the toronto-pm mailing list