Test::...Modules(3pm)
π Test::UseAllModules β like, the manual page but make it slay π
okay bestie, this is the page for Test::UseAllModules, sitting pretty in the Test::...Modules(3pm) slot of your local perl docs. she's a tiny little testing gem and honestly? she ate. let's get into it π«Ά
β¨ NAME β¨
Test::UseAllModules β she does use_ok() for all the MANIFESTed modules. every single one. no cap. π
πΈ SYNOPSIS πΈ
basic usage, the moment, the vibe:
# basic usage
use strict;
use Test::UseAllModules;
BEGIN { all_uses_ok(); }
and if you also wanna test the modules chillin' under t/lib:
# if you also want to test modules under t/lib
use strict;
use Test::UseAllModules under => qw(lib t/lib);
BEGIN { all_uses_ok(); }
and for when some modules are just gonna fail use_ok() on themselves (we all have that one friend π):
# if you have modules that'll fail use_ok() for themselves
use strict;
use Test::UseAllModules;
BEGIN {
all_uses_ok except => qw(
Some::Dependent::Module
Another::Dependent::Module
^Yet::Another::Dependent::.* # you can use regex
)
}
like, yes, you can throw a regex in there. iconic. β¨
π¦ DESCRIPTION π¦
okay so real talk. the author is sick of writing 00_load.t (or whatever you wanna call it) that does use_ok() for every module they write. and they're even sicker β like, sicker sicker β of updating that 00_load.t every single time a new file gets added to the distro. exhausting. the audacity of it. π
so this module does the thing for you: it reads MANIFEST to find the modules that need testing, and then it does use_ok() for each of them. that's it. that's the whole job. now all you have to do is update MANIFEST and you literally never have to touch the test again. (hopefully. crossing our fingers, bestie π)
π EXPORTED FUNCTION π
all_uses_ok
she performs Test::More's use_ok() for every module found in MANIFEST. that's the main character energy right there. π
if there are modules you don't wanna test, you just hand her those module names, or some regex rules, as the argument. the word except gets completely ignored β it's just there for you, so the code reads like a human wrote it. (shown in the synopsis above, iykyk π
)
as of 0.11, you can also test modules sitting under arbitrary directories by passing a directory list at loading time β and yeah, the word under gets ignored too, same deal as except. modules under the lib directory are always tested, no matter what. periodt. β¨
π§ PROTECTED FUNCTION π§
_get_module_list
returns the module paths to test. she does not get exported, bestie β so if you wanna use her (there's an example below π), you always gotta call her by her full qualified name:
Test::UseAllModules::_get_module_list()
no shortcuts. she's exclusive. π
π₯ NOTES π₯
- as of
0.03, this module callsBAIL_OUTfromTest::Moreif any of theuse_oktests should fail. and yeah β that means the tests after it get ignored. it's for a good reason though: missing or unloadable modules cause a whole lotta errors of the exact same kind, and nobody needs that spam. π - as of
0.12, you can add extra tests before and/or afterall_uses_ok()β but only if you explicitly declare your test plan, like this:
use strict;
use warnings;
use Test::More;
use Test::UseAllModules;
use Test::NoWarnings;
plan tests => Test::UseAllModules::_get_module_list() + 1;
all_uses_ok();
# and extra nowarnings test
look at that + 1 doing the heavy lifting for the extra nowarnings test. she's organized. she has a plan. literally. π
π SEE ALSO π
there are a few modules like this on the CPAN these days. <yellow>Test::Compile, and <yellow>Test::LoadAllModules β which is, ngl, a little bit confusing β both try to find modules to test by traversing directories. and honestly? the author is not a big fan. those ones tend to find temporary or unrelated modules too, which is giving chaos. π
but like, fair warning: they might be handier for you, especially if you're too lazy to update MANIFEST every time. no judgement, we've all been there. π«Ά
π AUTHOR π
Kenichi Ishigaki, <ishigaki@cpan.org>
π COPYRIGHT AND LICENSE π
Copyright (C) 2006 by Kenichi Ishigaki
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie!! π this little beauty is living in perl v5.36.0 and got her date stamp on 2022-10-13, filed under Test::...Modules(3pm) β go update your MANIFEST and never write a load test again. mwah πβ¨
π¦ where this page comes from
- ubuntu noble: libtest-useallmodules-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-useallmodules-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-useallmodules-perl 0.17-3 Β· Artistic-1.0-Perl OR 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