1Test::Needs(3)        User Contributed Perl Documentation       Test::Needs(3)
2
3
4

NAME

6       Test::Needs - Skip tests when modules not available
7

SYNOPSIS

9         # need one module
10         use Test::Needs 'Some::Module';
11
12         # need multiple modules
13         use Test::Needs 'Some::Module', 'Some::Other::Module';
14
15         # need a given version of a module
16         use Test::Needs {
17           'Some::Module' => '1.005',
18         };
19
20         # check later
21         use Test::Needs;
22         test_needs 'Some::Module';
23
24         # skips remainder of subtest
25         use Test::More;
26         use Test::Needs;
27         subtest 'my subtest' => sub {
28           test_needs 'Some::Module';
29           ...
30         };
31
32         # check perl version
33         use Test::Needs { perl => 5.020 };
34

DESCRIPTION

36       Skip test scripts if modules are not available.  The requested modules
37       will be loaded, and optionally have their versions checked.  If the
38       module is missing, the test script will be skipped.  Modules that are
39       found but fail to compile will exit with an error rather than skip.
40
41       If used in a subtest, the remainder of the subtest will be skipped.
42
43       Skipping will work even if some tests have already been run, or if a
44       plan has been declared.
45
46       Versions are checked via a "$module->VERSION($wanted_version)" call.
47       Versions must be provided in a format that will be accepted.  No extra
48       processing is done on them.
49
50       If "perl" is used as a module, the version is checked against the
51       running perl version ($]).  The version can be specified as a number,
52       dotted-decimal string, v-string, or version object.
53
54       If the "RELEASE_TESTING" environment variable is set, the tests will
55       fail rather than skip.  Subtests will be aborted, but the test script
56       will continue running after that point.
57

EXPORTS

59   test_needs
60       Has the same interface as when using Test::Needs in a "use".
61

SEE ALSO

63       Test::Requires
64           A similar module, with some important differences.  Test::Requires
65           will act as a "use" statement (despite its name), calling the
66           import sub.  Under "RELEASE_TESTING", it will BAIL_OUT if a module
67           fails to load rather than using a normal test fail.  It also
68           doesn't distinguish between missing modules and broken modules.
69
70       Test2::Require::Module
71           Part of the Test2 ecosystem.  Only supports running as a "use"
72           command to skip an entire plan.
73
74       Test2::Require::Perl
75           Part of the Test2 ecosystem.  Only supports running as a "use"
76           command to skip an entire plan.  Checks perl versions.
77
78       Test::If
79           Acts as a "use" statement.  Only supports running as a "use"
80           command to skip an entire plan.  Can skip based on subref results.
81

AUTHORS

83       haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>
84

CONTRIBUTORS

86       None so far.
87
89       Copyright (c) 2016 the Test::Needs "AUTHORS" and "CONTRIBUTORS" as
90       listed above.
91
92       This library is free software and may be distributed under the same
93       terms as perl itself. See <http://dev.perl.org/licenses/>.
94
95
96
97perl v5.30.0                      2019-07-26                    Test::Needs(3)
Impressum