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

NAME

6       Test::API - Test a list of subroutines provided by a module
7

VERSION

9       version 0.010
10

SYNOPSIS

12           use Test::More tests => 3;
13           use Test::API;
14
15           require_ok( 'My::Package' );
16
17           public_ok ( 'My::Package', @names );
18
19           import_ok ( 'My::Package',
20               export    => [ 'foo', 'bar' ],
21               export_ok => [ 'baz', 'bam' ],
22           );
23
24           class_api_ok( 'My::Class', @methods );
25

DESCRIPTION

27       This simple test module checks the subroutines provided by a module.
28       This is useful for confirming a planned API in testing and ensuring
29       that other functions aren't unintentionally included via import.
30

USAGE

32       Note: Subroutines starting with an underscore are ignored, as are a
33       number of other methods not intended to be called directly by end-
34       users.
35
36         import unimport bootstrap
37
38         AUTOLOAD BUILD BUILDARGS CLONE CLONE_SKIP DESTROY DEMOLISH
39
40         TIESCALAR TIEARRAY TIEHASH TIEHANDLE
41
42         FETCH STORE UNTIE FETCHSIZE STORESIZE POP PUSH SHIFT UNSHIFT SPLICE
43         DELETE EXISTS EXTEND CLEAR FIRSTKEY NEXTKEY PRINT PRINTF WRITE
44         READLINE GETC READ CLOSE BINMODE OPEN EOF FILENO SEEK TELL SCALAR
45
46         MODIFY_REF_ATTRIBUTES MODIFY_SCALAR_ATTRIBUTES MODIFY_ARRAY_ATTRIBUTES
47         MODIFY_HASH_ATTRIBUTES MODIFY_CODE_ATTRIBUTES MODIFY_GLOB_ATTRIBUTES
48         MODIFY_FORMAT_ATTRIBUTES MODIFY_IO_ATTRIBUTES
49
50         FETCH_REF_ATTRIBUTES FETCH_SCALAR_ATTRIBUTES FETCH_ARRAY_ATTRIBUTES
51         FETCH_HASH_ATTRIBUTES FETCH_CODE_ATTRIBUTES FETCH_GLOB_ATTRIBUTES
52         FETCH_FORMAT_ATTRIBUTES FETCH_IO_ATTRIBUTES
53
54       Therefore, do not include any of these in a list of expected
55       subroutines.
56
57   public_ok
58         public_ok( $package, @names );
59
60       This function checks that all of the @names provided are available
61       within the $package namespace and that *only* these subroutines are
62       available.  This means that subroutines imported from other modules
63       will cause this test to fail unless they are explicitly included in
64       @names.
65
66   class_api_ok
67         class_api_ok( $class, @names );
68
69       A variation of "public_ok" for object-oriented modules. Allows
70       superclasses to fill in "missing" subroutines, but "extra" methods
71       provided by superclasses will not cause the test to fail.
72
73   import_ok
74         import_ok ( $package, %spec );
75
76       This function checks that $package correctly exports an expected list
77       of subroutines and *only* these subroutines.  The %spec generally
78       follows the style used by [Exporter], but in lower case:
79
80         %spec = (
81           export    => [ 'foo', 'bar' ],  # exported automatically
82           export_ok => [ 'baz', 'bam' ],  # optional exports
83         );
84
85       For "export_ok", the test will check for public functions not listed in
86       "export" or "export_ok" that can be imported and will fail if any are
87       found.
88

SEE ALSO

90       ·   Test::ClassAPI -- more geared towards class trees with inheritance
91

SUPPORT

93   Bugs / Feature Requests
94       Please report any bugs or feature requests through the issue tracker at
95       <https://github.com/dagolden/Test-API/issues>.  You will be notified
96       automatically of any progress on your issue.
97
98   Source Code
99       This is open source software.  The code repository is available for
100       public review and contribution under the terms of the license.
101
102       <https://github.com/dagolden/Test-API>
103
104         git clone https://github.com/dagolden/Test-API.git
105

AUTHOR

107       David Golden <dagolden@cpan.org>
108

CONTRIBUTORS

110       ·   cpansprout <cpansprout@gmail.com>
111
112       ·   Toby Inkster <mail@tobyinkster.co.uk>
113
115       This software is Copyright (c) 2018 by David Golden.
116
117       This is free software, licensed under:
118
119         The Apache License, Version 2.0, January 2004
120
121
122
123perl v5.30.0                      2019-07-26                      Test::API(3)
Impressum