in reply to Testing Question

The Test::More diag function is intended for printing out diagnostics during a test run (which I think is what you're after). Also, to output all the test names during a run you can execute

prove -vb t/

instead of make test. That being said, I don't think I entirely understand your purpose here, as far as I'm concerned the test suite is supposed to consist of a list of simple checks, to make it easier to determine the cause (or at least locality) of a failure. Printing out debugging output during a normal test run doesn't seem particularly helpful to me (ok, if you're in the process of debugging a particular problem perhaps, but I'd remove that output once I've solved the problem)


All dogma is stupid.

Replies are listed 'Best First'.
Re^2: Testing Question
by pileofrogs (Priest) on Feb 24, 2006 at 19:45 UTC

    I find debugging output really helpful during development. I don't want to write-remove-write-remove debugging code ad-nausium. Plus, I often find that my problem really comes from somewhere other than the place where the symptoms are. If foo($thing) is breaking, but the problem is in the part that created $thing, I'd be much better off with complete debugging output, rather than having to put a bunch of stuff into foo(), just to discover that I need to put a bunch of stuff elsewhere. With reasonable debugging output, I'd already have both.

    Thanks for the pointers on prove and diag!

      If foo($thing) is breaking, but the problem is in the part that created $thing

      Then this should be caught by the tests for that part. That's kinda my point, by relying on debugging output which you inspect manually you're hiding the complexity of your program and missing out on vital tests. You are obviously smarter than your test suite and you can reason "ok, this is the output I was expecting, because I know of this side-effect which I'm not testing for otherwise". But this grows too complicated really quickly and IMO it'd be much better to write simple tests for everything so there are no untested side-effects. This way you don't risk missing out on an unexpected value.

      Obviously we all have our own methodology and I'm not trying to foist my way of thinking on you or tell you that you're wrong. Just trying to explain how I've found things work best for me.


      All dogma is stupid.

        ++

        Good points!

        So, if I can bother to write a 'print' statement, I can bother to write a test, is basically what you're saying. That coupled with the diag() function in Test::More will go a long way...

        I think what I really need to do is use the perl debugger more. If I wrote tests like you say and ran them in the debugger, I'd get everything I wanted.