Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^13: Self Testing Modules

by adrianh (Chancellor)
on Dec 21, 2005 at 10:41 UTC ( #518275=note: print w/replies, xml ) Need Help??

in reply to Re^12: Self Testing Modules
in thread Self Testing Modules

I built a patch for a couple of modules and found myself having to go through and renumber all the testcases after the position I inserted my test.

Then that module has a pretty darn odd way of doing test cases. I've never had to explicitly number a test. There isn't even an API for explicit test numbers in Test::Builder!

More recently I tried to track down the source of a failure reported as "Hmmm. Looks like test 27 failed", or similar and found myself having to plod through the test file counting manually to work out which was test 27. Less than easy as the were a lot of tests commented out.
Either way, a line number of the failing testcase, and a traceback to the point of failure would be a lot more useful.

Good test descriptions help with this and any standard Test::Builder based module will report the line number of the failing test case.

#! /usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; is 1+1, 2, 'addition works'; is 2*2, 5, 'oops - silly me'; __END__ # outputs ok 1 - addition works not ok 2 - oops - silly me # Failed test 'oops - silly me' # in foo.t at line 8. # got: '4' # expected: '5' 1..2

Replies are listed 'Best First'.
Re^14: Self Testing Modules
by BrowserUk (Pope) on Dec 21, 2005 at 13:21 UTC

    Would you care to consider how many modules on CPAN predate "the standard" Test::Builder?

    Or how many authors specify a plan?

    I suppose that it would be labouring my point to suggest that of the output shown, only 1 line (the 4th) of the 7 is of any use to me at all, and that still tells me nothing about where the error occurred in the module being tested.

    Good test descriptions help with this

    With line numbers, I don't need to add test descriptions, good or bad. That's another piece of effort that it removes from the programmer.

    Why force the programmer to translate the automatically assigned, automatically mainatained, unique identifier that a line number is, into a textual description that requires careful consideration to come up with a "good description", and force the tester (whether the original programmer, a maintanence programmer coming along later with a completely different mindset for who the original "good description" means absolutely nothing, or a user for whom it will probably never mean anything), back into a line number?

    What purpose did all that extra effort serve?

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://518275]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2021-06-18 00:11 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (86 votes). Check out past polls.