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

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

Paul Marquess
August 28, 2001 06:29
RE: [PATCH pod/perlhack.pod t/op/pack.t] Fixing bad testing advice
Message ID:
From: Robin Houston []
> 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.
> Could you explain the advantage of having a "simple ok() function"?
> As somebody who has spent many painful hours debugging test failures,
> I'm intimately familiar with the _disadvantages_. When you run the
> test, you know that "test 113 failed". That's all you know, in general.
> It's bad enough having to count the ocurrences of the ok() function to
> find out *which* test failed; and it's made considerably worse when,
> as is often the case, some of the ok()s are in loops.
> When tests are written in the naive style, life is much simpler. A
> simple "/ok 113" in vi will usually suffice to locate the offending
> test. Even if the failing test is in a loop, it's easy to tell what
> range of test numbers are encompassed by a particular loop.
> The "simple ok() function" may make test scripts easier to write,
> but it makes them a *lot* more difficult to use.

In my modules I use an ok sub, but I tell it the test number

    ok 23, $sometest eq $something ;

I use a script to automatically renumber them when I add or delete tests.


Do You Yahoo!?
Get your free address at Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About