Test::use::ok - Alternative to Test::More::use_ok
use ok 'Some::Module';
According to theTest::More documentation, it is recommended to runuse_ok()
inside aBEGIN
block, so functions are exported at compile-time and prototypes are properly honored.
That is, instead of writing this:
use_ok( 'Some::Module' );use_ok( 'Other::Module' );
One should write this:
BEGIN { use_ok( 'Some::Module' ); }BEGIN { use_ok( 'Other::Module' ); }
However, people often either forget to addBEGIN
, or mistakenly groupuse_ok
with other tests in a singleBEGIN
block, which can create subtle differences in execution order.
With this module, simply change alluse_ok
in test scripts touse ok
, and they will be executed atBEGIN
time. The explicit space afteruse
makes it clear that this is a single compile-time action.
To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights toTest-use-ok.
This work is published from Taiwan.
Perldoc Browser is maintained by Dan Book (DBOOK). Please contact him via theGitHub issue tracker oremail regarding any issues with the site itself, search, or rendering of documentation.
The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via thePerl issue tracker, themailing list, orIRC to report any issues with the contents or format of the documentation.