Test::Requires(3)
π Test::Requires β the vibe check for your modules, bestie β¨
Okay so real talk: this is the manual page for Test::Requires, and it's genuinely one of those tiny modules that just gets it. No cap. Let's break it down together π«Ά
β¨ NAME β¨
Test::Requires β it literally just checks to see if the module can be loaded. That's the whole job. Iconic, low-effort, high-impact π
πΈ SYNOPSIS πΈ
So here's how you actually use it, in all its forms. Copy these exactly, bestie, don't freestyle π
# in your Makefile.PL
use inc::Module::Install;
test_requires 'Test::Requires';
# in your test
use Test::More tests => 10;
use Test::Requires {
'HTTP::MobileAttribute' => 0.01, # skip all if HTTP::MobileAttribute doesn't installed
};
isa_ok HTTP::MobileAttribute->new, 'HTTP::MobileAttribute::NonMobile';
# or
use Test::More tests => 10;
use Test::Requires qw(
HTTP::MobileAttribute
);
isa_ok HTTP::MobileAttribute->new, 'HTTP::MobileAttribute::NonMobile';
# or
use Test::More tests => 10;
use Test::Requires;
test_requires 'Some::Optional::Test::Required::Modules';
isa_ok HTTP::MobileAttribute->new, 'HTTP::MobileAttribute::NonMobile';
Likeβ¦ pick whichever flavor speaks to you, they all slay π
π¦ DESCRIPTION π¦
So Test::Requires checks to see if the module can be loaded. That's it. That's the whole mood β¨
And here's the cute part: if this fails, it doesn't fail your tests β it skips all of them instead. It's giving "no drama, just gracefully stepping aside" energy π
It can also be used to require a minimum version of Perl, which is honestly so useful:
use Test::Requires "5.010"; # quoting is necessary!!
# or
use Test::Requires "v5.10";
β οΈ Bestie, notice that # quoting is necessary!! comment? Yeah. Quote it. Don't come crying to me when it breaks π
π AUTHOR π
Tokuhiro Matsuno <tokuhirom @*(#RJKLFHFSDLJF gmail.com>
(Yes, that email is exactly as cursed as it looks. I don't make the rules, I just report them π)
π THANKS TO π
These absolute legends made it happen:
kazuho++ # some tricky stuff
miyagawa++ # original code from t/TestPlagger.pm
tomyhero++ # reported issue related older test::builder
tobyink++ # documented that Test::Requires "5.010" works
We stan a collaborative community π«Άβ¨
π ENVIRONMENT π
So there's this environment variable, right? If RELEASE_TESTING is true, then instead of skipping tests, Test::Requires bails out. Different energy entirely β that's the "we're not playing around anymore" mode π
π₯
π§ SEE ALSO π§
"TestPlagger.pm"intβ go look, iykyk π
π LICENSE π
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Slay, open source queen ππΈ
Okay bestie, that's the whole page π This iconic documentation was brought to you by perl v5.42.0, dated 2020-05-14, and honestly? A moment. Periodt. πβ¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Requires 0.11-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms