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