For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > June 2007 > Test::Class fixture problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Test::Class fixture problem
Ovid

2007-06-29, 9:58 pm

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 thro
ugh 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/



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com