develooper Front page | perl.perl5.porters | Postings from August 2001

Re: [PATCH pod/perlhack.pod t/op/pack.t] Fixing bad testing advice

From:
Nicholas Clark
Date:
August 28, 2001 06:25
Subject:
Re: [PATCH pod/perlhack.pod t/op/pack.t] Fixing bad testing advice
Message ID:
20010828142506.B4950@plum.flirble.org
On Tue, Aug 28, 2001 at 02:12:46PM +0100, Robin Houston wrote:
> Michael Schwern wrote:
> > Ah HA!  I've been wondering why nobody ever thinks to write a simple
> > ok() function for their tests!  perlhack has bad testing advice.

> The "simple ok() function" may make test scripts easier to write,
> but it makes them a *lot* more difficult to use.
> 
> One compromise would be to use a test-generating script, which allows
> the tests to be structured simply and _generates_ the actual test
> code. One could then grep the generated test script to locate the
> failing code.

Another would be to make a small ok function from something that can be
cut&pasted into any of the core perl tests (ie stuff before lib/)
Something that will issue a comment using caller() to find the line number
of the failing test, and let the user pass in names for the tests.

Alternatively an ok() function and encouraging a style of

ok ($schwern->DonateBucksToYAS(500))
  or print "# Schwern still has the money - there are " .
	$core->countUntestedModules() . " untested modules in the core\n";

to print a name and diagnostic data for the failing test should also make
tracing test problems easier.

(I agree with Robin - try tracking bugs in op/pack.t)

Nicholas Clark



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About