Test::Able::Runner - use Test::Able without a bunch of boilerplate
version 1.002
use Test::Able::Runner; use_test_packages -base_package => 'My::Project::Test'; run;
I like Test::Able. I really don't like having to copy my boilerplate test runner and modify it when I use it in a new project. This provides a basic test runner for your testable tests that takes care of the basics for you. You can extend it a bit to customize things if you like as well. Let me know if you want this to do something else.
This mostly assumes that you want to run several tests as a group within a single Perl interpreter. If this is not what you want, then you probably don't want this module.
The first thing your test runner needs to do is call this method to tell it what packages need to be included in your test.
Before describing the options, here are some examples of how to use this subroutine.
use_test_packages -base_package => 'My::Project::Test', -test_path => 't/lib';
This is pretty much the simplest case. This will load and run all the packages starting with the name "My::Project::Test" found in the project's t/lib directory. I show the -test_path option here, but in this case it's redundant. Your test path is assumed to be t/lib in the usual case.
-test_path
use_test_packages -test_packages => [ qw( My::Project::Test::One My::Project::Test::Two My::Project::Test::Three ) ];
Rather than searching for any test packages you might have in your test folder, you might prefer to explicitly list them.
-base_package
This is the package namespace to search for classes within. Any class found under this namespace (within any directory included in -test_path) will be run in your tests. If you want to include classes under this base package namespace that are not tests (test roles or base classes or whatever), you may place a global package variable within the package named $NOT_A_TEST and set it to a true value:
$NOT_A_TEST
package My::Project::Test::Base; use Test::Able; our $NOT_A_TEST = 1;
You may use this option or the -test_packages option. This may be a single scalar package name
-test_packages
This is the list of test packages to load and run. It is always given as an array of package names.
This is the search path for test classes. This lists additional paths that should be added to @INC to search for tests before loading the tests. These paths are added to the front of @INC.
@INC
It can be given as a single scalar or as an array of paths:
use_test_packages -base_package => 'My::Project::Test', -test_path => [ 't/online', 't/offline' ];
Sets up your test runner package.
This invokes the test runner for all the tests you've requested.
Here are some other things you might like to try.
The test runner itself may have tests if you want. The test runner classes uses the usual Test::Able bits, so this works. Similarly, you can do setup, teardown, and all the rest in your runner.
use Test::Able::Runner; use_test_packages -base_package => 'Foo::Test'; test plan => 1, test_something => sub { ok(1); }; run;
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
<hanenkamp@cpan.org>
Copyright 2010 Qubling Software LLC.
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::Able::Runner, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Able::Runner
CPAN shell
perl -MCPAN -e shell install Test::Able::Runner
For more information on module installation, please visit the detailed CPAN module installation guide.