Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Universal test flag

by ait (Friar)
on Jul 17, 2012 at 13:17 UTC ( #982232=note: print w/ replies, xml ) Need Help??


in reply to Re: Universal test flag
in thread Universal test flag

Thanks for your comment. Yes, I understand your concern and I second your opinion that print statements for debugging are a bad idea, one of the reasons I looked into using callbacks that could allow the test software to inspect intermediate results within a sub. There are some situations (e.g. "large amount of state data shared among the different steps of a function" see 880089) in which intermediate values inside a sub need to be evaluated, but instead of printing these ase debug statements I have been using a "test point" analogy that I describe here 882331. This allows a your test to diagnose the problem better before firing up the debugger to fix it.

Of course many of this situations can be avoided with better design, but in the real world time and budget constraints don't allow for adequate refactoring to fix these design problems. The test point idea was precisely for eliminating all these print-debug statements and move these intermediate values to be evaluated in the test suite instead of reading and making sense of all the verbose debug statements.


Comment on Re^2: Universal test flag
Re^3: Universal test flag
by bulk88 (Priest) on Jul 17, 2012 at 15:19 UTC

      Exactly! That is precisely the idea: to give a more intelligible diagnostic message instead of having to go through millions of debug messages.

      Whilst the general consensus that the smallest testable unit is a sub, in many real world applications this is simply not the case. A lot of business code has a lot of state data shared in long subroutines. They are always room for refactoring but in the mean time, you need to provide mechanisms to test this code the best you can.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2014-09-18 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (108 votes), past polls