# from Ovid
# on Monday 09 November 2009 02:11:

>but can be viewed as tests themselves!  If either "use My::Module" or
> "require My::Module" fails, ...

Yeah, that's how I always do it.

>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.

Yep.

Packaging that idiom into something that runs at BEGIN via import() 
would qualify as progress.  So I can get BAIL_OUT() semantics for all 
of my tests with e.g.

  use Test::More require => 'My::Module';

Though I would love to get the parser to gimme the bareword treatment of 
the module name there somehow.  Not sure if that can be kept in BEGIN 
without contortions.

  use Test::More sub { require My::Module };

Or, possibly I just want automagic BAIL_OUT() if we fail in BEGIN, so:

  use Test::More autobail => 'BEGIN';
  use My::Module;

Anyway, no I don't use use_ok()/require_ok() and they should be 
discouraged.  But, what can you do to purge them from the dozens of 
random tutorials and somehow issue a cargo-culting recall?

--Eric
-- 
If the above message is encrypted and you have lost your pgp key, please
send a self-addressed, stamped lead box to the address below.
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to