Test::use::ok(3)

πŸ“¦ version 1.302214, in opensuse-leap 16.0

🌸 NAME 🌸

Okay so bestie, welcome to the Test::use::ok(3) page β€” from the User Contributed Perl Documentation shelf, no less. This module is literally the alternative to Test::More::use_ok, and its whole vibe is making your test scripts behave at BEGIN time without you having to remember extra BEGIN scaffolding. Iconic behavior, honestly.


✨ SYNOPSIS ✨

use ok 'Some::Module';

That’s it. That’s the whole synopsis. Short, sweet, and serving main character energy πŸ’….


πŸ¦‹ DESCRIPTION πŸ¦‹

So, according to the Test::More documentation, the recommended move is to run use_ok() inside a BEGIN block β€” that way functions are exported at compile-time and prototypes are properly honored. The docs said it, so we respect it, periodt.

That means instead of writing this:

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

You should write this:

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

And like… valid. But ngl, people often either forget to add BEGIN, or they mistakenly group use_ok with other tests in a single BEGIN block. And that can create subtle differences in execution order. Not a slay. More of a β€œwait, why is this test acting weird” moment 😭.

With this module, you simply change all use_ok in test scripts to use ok, and they will be executed at BEGIN time. The explicit space after use makes it clear that this is a single compile-time action. The way that works is genuinely so clean. Obsessed 🫢.


πŸ”₯ SEE ALSO πŸ”₯

  • Test::More β€” the icon, the legend, the reference point. Go read it, iykyk πŸ’œ.

πŸ‘‘ MAINTAINER πŸ‘‘

Chad Granum <exodist@cpan.org> β€” that’s the maintainer, bestie. Respect the name, fr fr πŸ’–.


🌈 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/>


Sign-off sparkle: this adorable little page is rockin’ perl v5.42.0, dated 2025-07-28, and yes bestie, it’s still Test::use::ok(3) β€” bye, love u, go write those tests πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from