Test::use::ok(3perl)

✨ Test::use::ok ✨

okay bestie, gather round, because this little page is literally about Test::use::ok β€” it's the Alternative to Test::More::use_ok and it is so much less stressful than what you're probably doing right now. πŸ’–

This is part of the Perl Programmers Reference Guide, so you know it's official official. πŸ‘‘


🌸 SYNOPSIS 🌸

use ok 'Some::Module';

that's it. that's the whole vibe. one line, no BEGIN, no drama. ✨


πŸ’… DESCRIPTION πŸ’…

so here's the tea, straight from the Test::More documentation: it is recommended that you run use_ok() inside a BEGIN block. why? because that way your functions get exported at compile-time and prototypes are properly honored. no cap. 🫢

so like, instead of writing this cursed little guy:

use_ok( 'Some::Module' );
use_ok( 'Other::Module' );

you're supposed to write this:

BEGIN { use_ok( 'Some::Module' ); }
BEGIN { use_ok( 'Other::Module' ); }

and like… yeah. but be honest bestie, people constantly either forget to add that BEGIN, or they mistakenly group use_ok together with other tests in one single BEGIN block β€” and that lowkey creates subtle differences in execution order and now your test suite is giving chaos. 😭

and THAT is where this module comes in, saving the day, main character energy only. πŸ’…

with Test::use::ok, you simply go through every single use_ok in your test scripts and change it to:

use ok

and boom β€” they all get executed at BEGIN time, automatically, like magic. πŸ¦‹βœ¨

and the cute part? that explicit space between use and ok is doing a whole job: it makes it clear that this is a single compile-time action. iconic design choice, honestly. it's giving thoughtful. 🌈


πŸŽ€ SEE ALSO πŸŽ€

  • Test::More β€” the origin story, go read it

πŸ‘‘ MAINTAINER πŸ‘‘

  • Chad Granum β€” <exodist@cpan.org>

⭐ CC0 1.0 Universal ⭐

To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Test::use::ok.

This work is published from Taiwan. 🌸

<https://creativecommons.org/publicdomain/zero/1.0/>


okay that's the whole page, bestie, you're all caught up πŸ’– this was Test::use::ok(3perl) from perl v5.44.0, dated 2026-10-17 β€” slay, go write some tests, and remember: use ok > use_ok, periodt. πŸ‘‘βœ¨πŸŽ€

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms