The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::AllModules - do some tests for modules in search path

SYNOPSIS

    use Test::AllModules;

    BEGIN {
        all_ok(
            search_path => 'MyApp',
            check => sub {
                my $class = shift;
                eval "use $class;1;";
            },
        );
    }

Here is also same as above: simplest one.

    use Test::AllModules;

    BEGIN {
        all_ok(
            search_path => 'MyApp',
            use => 1,
        );
    }

DESCRIPTION

Test::AllModules is do some tests for modules in search path.

EXPORTED FUNCTIONS

all_ok(%args)

do check(s) code as Test::More::ok() for every module in search path.

  • 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.

    This parameter is optional.

  • require => boolean

    If this option sets true value then do a load module(require) test.

    This parameter is optional.

  • 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 is passed to Test::More::ok().

  • except => \@array: include scalar or qr//

    This parameter is optional.

  • lib => \@array

    Additional library paths.

    This parameter is optional.

  • 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.

    This parameter is optional.

    NOTE that this option is NOT supported in Windows system.

  • shuffle => boolean

    If this option was set the true value then modules will be sorted in random order.

    This parameter is optional.

  • show_version => boolean

    If this option was set the true value then the version of module will be shown.

    This parameter is optional.

EXAMPLES

if you need the name of test

    use Test::AllModules;

    BEGIN {
        all_ok(
            search_path => 'MyApp',
            check => +{
                'use_ok' => sub {
                    my $class = shift;
                    eval "use $class;1;";
                },
            },
        );
    }

actually the count is also passed

    use Test::AllModules;

    BEGIN {
        all_ok(
            search_path => 'MyApp',
            check => sub {
                my ($class, $count) = @_;
                eval "use $class;1;";
            },
        );
    }

more tests, all options

    use Test::AllModules;

    BEGIN {
        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,
        );
    }

REPOSITORY

Test::AllModules is hosted on github <http://github.com/bayashi/Test-AllModules>

AUTHOR

dann

Dai Okabayashi <bayashi@cpan.org>

SEE ALSO

Test::LoadAllModules

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.