From: Yuval Kogman <[EMAIL PROTECTED]>

> What about
>
>    $some_object->send_email(@args);
>
> and having your test code:
>
>    a. replace the object (probably a singleton or an obj in a
>    global) with a mock object that doesn't actually send email
>
>    b. also test that send_email is being called when appropriate

While that's the general strategy, this is working with a lot of legacy code 
which is, to be kind, not written to today's standards.  Fortunately, most of 
this code already checks an $ENV{DEVEL} variable.  Merely by ensuring that this 
variable is set to a true value, I can protect against much of the worst.  
There's simply no way I can go through all of the code right now and possibly 
hope to catch all cases where things might blow up.  The 'My::Test::Class' 
solution seems to work now.  

(You know, you could probably use that to do interesting things like caching 
the last time a given developer ran tests.  Hmm, why anyone want to do that?)

Just to give you an idea of the problem I'm faced with:  
http://use.perl.org/~Ovid/journal/31057

Cheers,
Ovid
 
-- 
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/




Reply via email to