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

AUTHOR

75       haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>
76

CONTRIBUTORS

78       None so far.
79
81       Copyright (c) 2016 the Test::Needs "AUTHOR" and "CONTRIBUTORS" as
82       listed above.
83

LICENSE

85       This library is free software and may be distributed under the same
86       terms as perl itself. See <http://dev.perl.org/licenses/>.
87
88
89
90perl v5.28.1                      2016-09-27                    Test::Needs(3)
Impressum