Menu

#6 configurable Test::Unit::TestCase::debug() method

closed-wont-fix
nobody
Feature (3)
5
2001-03-01
2001-02-01
No

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 { })
);
}

Discussion

  • Matthew Astley

    Matthew Astley - 2001-02-01

    None

     
  • Matthew Astley

    Matthew Astley - 2001-02-01

    Hmm, view the source to get the code in a sane form. Maybe I should put some <pre>s in?</pre>

     
  • Christian Lemburg

    Sorry if I don't get it at once, but what usage scenario is this exactly for?

     
  • Matthew Astley

    Matthew Astley - 2001-02-06

    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() }

     
  • Matthew Astley

    Matthew Astley - 2001-02-19
    • labels: 300100 --> Feature
     
  • Matthew Astley

    Matthew Astley - 2001-03-01
    • status: open --> closed-wont-fix
     

Log in to post a comment.