I've been toying with this thought for a while: discourage (not quite 
deprecate) use_ok() and require_ok().  I've written up some of the problems 
with the former (http://use.perl.org/~Ovid/journal/39859) and the latter still 
has the "or die" problem.

For the life of me, I can't really see any utility to use_ok() or require_ok(). 
 Not only are both fragile and a source of strange "action at a distance" bugs, 
but the constructs they replace not only work correctly, but can be viewed as 
tests themselves!  If either "use My::Module" or "require My::Module" fails, 
the test program exits with a non-zero exit status, thus meaning a failure is 
reported.

What do people think?  Should we start discouraging the use of these tests?  
Maybe even go so far as to deprecate them?

The *only* use I've ever had for use_ok() has been in a t/00-load.t test which 
attempts to load all modules and does a BAIL_OUT if it fails.  I'm sure there 
are other use cases, but if that's the only one, it seems a very, very slim 
justification for a fragile code.  See my link for more explanation, including 
how Test::More's own docs get this wrong -- which alone should say something 
about how new testers will get this wrong when experienced testers do.

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to