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


Test-API documentation  | view source Contained in the Test-API distribution.

Index


NAME

Top

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

VERSION

Top

This documentation describes version 0.002.

SYNOPSIS

Top

     use Test::More tests => 3;
     use Test::API;

     require_ok( 'My::Package' );

     public_ok ( 'My::Package', @names );

     import_ok ( 'My::Package',
         export    => [ 'foo', 'bar' ],
         export_ok => [ 'baz', 'bam' ], 
     );

DESCRIPTION

Top

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

USAGE

Top

Note: Subroutines in a package starting with an underscore are ignored. Therefore, do not include them in any list of expected subroutines.

public_ok

   public_ok( $package, @names );

This function checks that all of the @names provided are available within the $package namespace and that only these subroutines are available. This means that subroutines imported from other modules will cause this test to fail unless they are explicitly included in @names.

import_ok

   import_ok ( $package, %spec );

This function checks that $package correctly exports an expected list of subroutines and only these subroutines. The %spec generally follows the style used by Exporter, but in lower case:

   %spec = (
     export    => [ 'foo', 'bar' ],  # exported automatically
     export_ok => [ 'baz', 'bam' ],  # optional exports
   );

For export_ok, the test will check for public functions not listed in export or export_ok that can be imported and will fail if any are found.

BUGS

Top

Please report any bugs or feature requests using the CPAN Request Tracker web interface at http://rt.cpan.org/Dist/Display.html?Queue=Test-API

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

Top

AUTHOR

Top

David A. Golden (DAGOLDEN)

COPYRIGHT AND LICENSE

Top


Test-API documentation  | view source Contained in the Test-API distribution.