Adam Turoff on Mon, 24 Jan 2000 18:03:17 -0500 (EST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Writing unit tests in Perl.


John Nolan wrote:
> Jim Wismer wrote:
> > I've been reading the XP book and am impressed with its focus on testing as
> > a basic coding task.  Writing effective unit tests is something I have never
> > really gotten a good grasp on, especially with Perl/CGI type applications.  
> > 
> > Anyone have any good pointers to tutorials/documentation/books that might
> > enlighten the novice test writer?
> 
> You probably thought of this already, but you might want
> to have a look at the regression tests that are included
> with a lot of Perl modules.  Some of these are quite lengthy
> and they test all sorts of features.  Off the top of my head,
> I don't remember what sort of tests CGI.pm has, but you might
> have a look at these, as an example of how to test a CGI program. 

Most large scale CGI apps are a blend of common modules and glue code.

Testing the common modules should be simple enough (in theory) that 
the unit testing framework for generic modules should work well. 

Testing the glue code (foo.cgi) might involve testing against a 
fully configured (skeletal) web server and using an LWP-based harness.
That is, starting a web server that can execute CGI, and writing small
bits of test code that use LWP::UserAgent (or something) to test the
full CGI application.

The glue code test may sound hairy, but the LWP test code already does
some of this (setting up a skeletal server to test a skeletal client
as part of 'make test').

As far as help on writing test code, I don't have many pointers in that
direction.  I don't think there's a doc on writing good test code 
in the perl docs.

Z.

**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**