1Test::UseAllModules(3)User Contributed Perl DocumentationTest::UseAllModules(3)
2
3
4
6 Test::UseAllModules - do use_ok() for all the MANIFESTed modules
7
9 # basic usage
10 use strict;
11 use Test::UseAllModules;
12
13 BEGIN { all_uses_ok(); }
14
15 # if you also want to test modules under t/lib
16 use strict;
17 use Test::UseAllModules under => qw(lib t/lib);
18
19 BEGIN { all_uses_ok(); }
20
21 # if you have modules that'll fail use_ok() for themselves
22 use strict;
23 use Test::UseAllModules;
24
25 BEGIN {
26 all_uses_ok except => qw(
27 Some::Dependent::Module
28 Another::Dependent::Module
29 ^Yet::Another::Dependent::.* # you can use regex
30 )
31 }
32
34 I'm sick of writing 00_load.t (or something like that) that'll do
35 use_ok() for every module I write. I'm sicker of updating 00_load.t
36 when I add another file to the distro. This module reads MANIFEST to
37 find modules to be tested and does use_ok() for each of them. Now all
38 you have to do is update MANIFEST. You don't have to modify the test
39 any more (hopefully).
40
42 all_uses_ok
43 Does Test::More's use_ok() for every module found in MANIFEST. If you
44 have modules you don't want to test, give those modules or some regex
45 rules as the argument. The word 'except' is ignored as shown above.
46
47 As of 0.11, you can also test modules under arbitrary directories by
48 providing a directory list at the loading time (the word 'under' is
49 ignored as shown above). Modules under the lib directory are always
50 tested.
51
53 _get_module_list
54 Returns module paths to test. This function will not be exported. If
55 you want to use this (see below), you always need to call it by the
56 full qualified name.
57
59 As of 0.03, this module calls BAIL_OUT of Test::More if any of the
60 use_ok tests should fail. (Thus the following tests will be ignored.
61 Missing or unloadable modules cause a lot of errors of the same kind.)
62
63 As of 0.12, you can add extra tests before/after all_uses_ok() if you
64 explicitly declare test plan like this.
65
66 use strict;
67 use warnings;
68 use Test::More;
69 use Test::UseAllModules;
70 use Test::NoWarnings;
71
72 plan tests => Test::UseAllModules::_get_module_list() + 1;
73
74 all_uses_ok();
75
76 # and extra nowarnings test
77
79 There're several modules like this on the CPAN now. Test::Compile and a
80 bit confusing Test::LoadAllModules try to find modules to test by
81 traversing directories. I'm not a big fan of them as they tend to find
82 temporary or unrelated modules as well, but they may be handier
83 especially if you're too lazy to update MANIFEST every time.
84
86 Kenichi Ishigaki, <ishigaki@cpan.org>
87
89 Copyright (C) 2006 by Kenichi Ishigaki
90
91 This library is free software; you can redistribute it and/or modify it
92 under the same terms as Perl itself.
93
94
95
96perl v5.34.0 2022-01-21 Test::UseAllModules(3)