From: Robin Houston [mailto:robin@kitsite.com] > 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. Paul _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.comThread Previous | Thread Next