configurable Test::Unit::TestCase::debug() method
Status: Beta
Brought to you by:
mca1001
If you call Test::Unit::TestSuite::set_debug(CODEREF) then the TestSuite::run() will set the debug function for all cases before they're started.
Otherwise the TestCase is left with a verbose death message explaining where to call set_debug().
The other place to set it is in the set_up() for an individual test:
sub set_up {
my $self = shift;
# this is only required if we call $self->debug() from a test
$self->set_debug($opts{'debug'}
? (sub { my $self = shift; print "dbg: @_\n"; })
: (sub { })
);
}
None
Hmm, view the source to get the code in a sane form. Maybe I should put some <pre>s in?</pre>
Sorry if I don't get it at once, but what usage scenario is this exactly for?
Original intention is for { $self->debug("gory details"); }
I needed somewhere to send debug messages, and I wanted to be independent of my package-global $opts{'debug'}. A package debug method would be fine for my internal code, but it seemed to be something lacking in the framework. The JUnit has some sort of debug log stream (haven't used it)...
I suspect this patch could mature a little if you see some value in it. Maybe debug by channel/level, or return values so you can do { $self->quell_backtrace() unless $self->debug() }