I wondered why this never showed up in PerlQA.
----- Forwarded Message ----
From: Ovid <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]; Adrian Howard <[EMAIL PROTECTED]>
Sent: Friday, June 29, 2007 4:23:15 PM
Subject: Test::Class fixture problem
I've just spent quite a bit of time debugging a problem where a Test::Class
setup method was misbehaving. My tests passed, but mysql was spitting out
errors directly to STDERR and quite a bit of tracing led me to the following:
sub setup : Tests(setup) {
my $test = shift;
$test->SUPER::startup;
$test->_make_test_servers(
num_servers => 2,
username => 'Ovid',
);
}
As you can see, I called SUPER::startup instead of SUPER::setup.
My base class has stubs for these methods to ensure that I never have a problem
with SUPER::
sub startup : Tests(startup) {}
sub setup : Tests(setup) {}
sub teardown : Tests(teardown) {}
sub shutdown : Tests(shutdown) {}
Sometimes in my hierarchy, though, the SUPER::startup (or whatever) method will
call a chain of two of these before getting to the stub. It's trivial to write
code in my stubs which check the caller and issue a warning and maybe I can
just walk back through the call stack to issue a warning if I'm ever called by
an inappropriately named method, but that seems a bit hackish. Is there some
better way to solve this problem?
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/