Wismer, James on Wed, 26 Jan 2000 11:45:05 -0500 (EST)


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

RE: Writing unit tests in Perl.


Title: RE: Writing unit tests in Perl.

Thanks to all for the great suggestions.  I think I will start by examining Perl module test scripts.

Are there any documented standards that module builders follow?  I saw in the tests for DBI a generic test script that the author suggests be used in generating new test cases.

On a more general note concerning XP, I find it difficult to understand how one might go about coding by first generating a set of tests and then coding until all tests work.  The concept is straightforward, but it seems to me that the difficult part is knowing when you have the "right" set of tests.  Maybe it will become clearer once I read the chapter on testing strategy.

Jim

-----Original Message-----
From: Kurt D. Starsinic [mailto:kstar@chapin.edu]
Sent: Monday, January 24, 2000 9:46 PM
To: phl@lists.pm.org
Subject: Re: Writing unit tests in Perl.


On Mon, Jan 24, 2000 at 09:05:53AM -0800, John Nolan 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.

    I would suggest that you start with the regression tests in Perl itself.
They're a veritable encyclopedia of testing techniques.  They can be found
in the t/ directory of any Perl source tarball.

    As to regression testing CGI in particular, Jim, you might want to look
at a tool called `webscript' that I wrote while under previous employment.
Ask Al Lee where to find it.  Open-sourcing it and uploading it to CPAN are
left as an Exercise for the Reader.

    Peace,
* Kurt Starsinic (kstar@orientation.com) ---------- Senior Network Engineer *
|      ``If people are boasting that they use the best tools, you can       |
|        figure that they can't find any competitive advantage to using     |
|        those tools, or else they wouldn't be presenting them as a         |
|        competitive advantage.'' -- Dave Winer                             |

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