Test::AllModules(3pm)

πŸ“¦ version 0.18, in alpine 3.24

✨ NAME ✨

Test::AllModules β€” do some tests for modules in search path. Also hi bestie, this whole page is the Test::AllModules(3pm) manual, and it's literally about testing every module your search path can find. 🫢

🌸 SYNOPSIS 🌸

Okay so first vibe:

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

πŸ¦‹ DESCRIPTION πŸ¦‹

Test::AllModules is do some tests for all modules in search path. That's the whole assignment, no cap. πŸ’…

πŸ’– 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 is set to a true value, then do a load module "use" test. This parameter is optional.
  • require => boolean β€” if this option is set to a true value, then do a load module "require" test. This parameter is optional.
  • no_import => boolean β€” if this option is set to a true value, then do not import any function when a test module is loaded. This parameter is optional.
  • check => \&test_code_ref or hash( TEST_NAME => \&test_code_ref ) β€” the code to execute for each module.
  • checks => \@array: include hash( TEST_NAME => \&test_code_ref ) β€” a list of those test code refs.

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 a true value if the test is OK. βœ…

  • except => \@array: include scalar or qr// β€” ignore modules. This parameter is optional.
  • lib => \@array β€” additional library paths. This parameter is optional.
  • fork => 1:fork, 2:fork and show PID β€” if this option is set to a value (1 or 2), then each check-code executes after forking. This parameter is optional.
NOTE that this "fork" option is NOT supported in Windows system.
  • shuffle => boolean β€” if this option is set to the true value, then modules will be sorted in random order. This parameter is optional.
  • show_version => boolean β€” if this option is set to the true value, then the version of module will be shown if it's possible. This parameter is optional.
  • 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.

This parameter is optional.

  • after_hook => code ref β€” this code ref executes after test.
after_hook  => sub {
    my ($ret, $test_code, $class, $count) = @_;

    # ... do something ...
},

This parameter is optional.

🌈 EXAMPLES 🌈

If you need the name of test, then you can use the check parameter: "check =" { test_name => sub { 'test' } }>.

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,
);

πŸ‘‘ REPOSITORY πŸ‘‘

Test::AllModules is hosted on github <http://github.com/bayashi/Test-AllModules>. Go star it maybe? πŸ‘‘

🫢 AUTHOR 🫢

dann

Dai Okabayashi <bayashi@cpan.org>

πŸ”₯ SEE ALSO πŸ”₯

Test::LoadAllModules β€” go look. πŸ”₯

πŸ’œ LICENSE πŸ’œ

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


Okay bestie, that's the whole page! Source/version: perl v5.42.2. Date: 2023-07-03. Manual: Test::AllModules(3pm). Bye, go run those tests πŸ’…βœ¨

πŸ“¦ where this page comes from