Test::AllModules - do some tests for modules in search path
use Test::AllModules; all_ok( search_path => 'MyApp', use => 1, );
Here is also same as above
use Test::AllModules; all_ok( search_path => 'MyApp', check => sub { my $class = shift; eval "use $class;1;"; }, );
Test::AllModules is do some tests for all modules in search path.
do check(s) code as Test::More::ok() for every module in search path.
check(s)
Test::More::ok()
search_path => 'Class'
A namespace to look in. see: Module::Pluggable::Object
use => boolean
If this option sets true value then do a load module(use) test.
use
This parameter is optional.
require => boolean
If this option sets true value then do a load module(require) test.
require
no_import => boolean
If this option sets true value then do not import any function when a test module is loaded.
check => \&test_code_ref or hash( TEST_NAME => \&test_code_ref )
checks => \@array: include hash( TEST_NAME => \&test_code_ref )
The code to execute each module. The code receives $class and $count. The result from the code will be passed to Test::More::ok(). So, test codes must return true value if test is OK.
$class
$count
except => \@array: include scalar or qr//
Ignore modules.
lib => \@array
Additional library paths.
fork => 1:fork, 2:fork and show PID
If this option was set a value(1 or 2) then each check-code executes after forking.
NOTE that this fork option is NOT supported in Windows system.
fork
shuffle => boolean
If this option was set the true value then modules will be sorted in random order.
show_version => boolean
If this option was set the true value then the version of module will be shown if it's possible.
before_hook => code ref
This code ref executes before test.
before_hook => sub { my ($test_code, $class, $count) = @_; # ... do something ... return; },
NOTE that if you return true value from before_hook, then the test will skip.
after_hook => code ref
This code ref executes after test.
after_hook => sub { my ($ret, $test_code, $class, $count) = @_; # ... do something ... },
If you need the name of test, then you can use check parameter: check = { test_name => sub { 'test' } }>
check =
use Test::AllModules; all_ok( search_path => 'MyApp', check => +{ 'use_ok' => sub { my ($class, $test_count) = @_; eval "use $class;1;"; }, }, );
more tests, all options
use Test::AllModules; all_ok( search_path => 'MyApp', use => 1, require => 1, checks => [ +{ 'use_ok' => sub { my $class = shift; eval "use $class; 1;"; }, }, ], except => [ 'MyApp::Role', qr/MyApp::Exclude::.*/, ], lib => [ 'lib', 't/lib', ], shuffle => 1, fork => 1, no_import => 1, );
Test::AllModules is hosted on github http://github.com/bayashi/Test-AllModules
dann
Dai Okabayashi <bayashi@cpan.org>
Test::LoadAllModules
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install Test::AllModules, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::AllModules
CPAN shell
perl -MCPAN -e shell install Test::AllModules
For more information on module installation, please visit the detailed CPAN module installation guide.