Test::Kit - Build custom test packages with only the features you want.
Version 0.02
package My::Custom::Tests; use Test::Kit 'Test::More', 'Test::XML', 'Test::Differences', '+explain', );
ALPH CODE! You've been warned.
kit:
kit
A set of materials or parts from which something can be assembled.
How many times have you opened up a test program in a large test suite and seen 5 or 6 use Test::... lines? And then you open up a bunch of other test programs and they all have the same 5 or 6 lines. That's duplication you don't want. Test::Kit allows you to safely push that code into one custom test package and merely use that package. It does this by treating various test module's functions as pieces you can assemble together.
use Test::...
Test::Kit
Also, you can import 'features' to extend your testing possibilities.
Create a package for your tests and add the test modules you want.
package My::Tests; use Test::Kit qw( Test::Differences Test::Exception );
Then in your test programs, all exported test functions from those modules will be available. Test::More functions are included by default.
Test::More
use My::Tests plan => 3; is 3, 3, 'this if from Test::More'; eq_or_diff [ 3, 3 ], [ 3, 3 ], 'this is from Test::Differences'; throws_ok { die 'test message' } qr/^test message/, '... and this is from Test::Exception';
Additional features, as detailed in Test::Kit::Features, are available. Two common features are 'explain' and 'on_fail'. To use a feature, just add a '+' (plus) before the feature name:
package My::Tests; use Test::Kit qw( Test::Differences Test::Exception Test::XML Test::JSON +explain +on_fail );
Sometimes two or more test modules may try to export a function with the same name. This will cause a compile time failure listing all which modules export which conflicting function. There are two ways of dealing with this: renaming and excluding. To do this, add a hashref after the module name with keys 'exclude', 'rename', or both.
use Test::Most 'Test::Something' => { # or a scalar for just one exclude => [qw/ list of excluded functions/], }, 'Test::Something::Else' => { # takes a hashref rename => { old_test_function_name => 'new_test_function_name', }, }, '+explain';
Curtis "Ovid" Poe, <ovid at cpan.org>
<ovid at cpan.org>
Please report any bugs or feature requests to bug-test-kit at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Kit. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-test-kit at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Test::Kit
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Kit
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Test-Kit
CPAN Ratings
http://cpanratings.perl.org/d/Test-Kit
Search CPAN
http://search.cpan.org/dist/Test-Kit
Copyright 2008 Curtis "Ovid" Poe, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::Kit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Kit
CPAN shell
perl -MCPAN -e shell install Test::Kit
For more information on module installation, please visit the detailed CPAN module installation guide.