NAME
Test::Aggregate - Aggregate *.t
tests to make them run faster.
VERSION
Version 0.01
SYNOPSIS
use Test::Aggregate;
Test::Aggregate->runtests($dir);
DESCRIPTION
WARNING: this is ALPHA code. The interface is not guaranteed to be stable.
A common problem with many test suites is that they can take a long time to run. The longer they run, the less likely you are to run the tests. This module borrows a trick from Apache::Registry
to load up your tests at once, create a separate package for each test and wraps the code in a method named run_the_tests
. This allows us to load perl only once and related modules only once. If you have modules which are expensive to load, this can dramatically speed up a test suite.
USAGE
Create a separate directory for your tests. This should not be a subdirectory of your regular test directory. Write a small driver program and put it in your regular test directory (t/
is the standard):
use Test::Aggregate;
my $other_test_dir = 'aggregate_tests';
Test::Aggregate->runtests($other_test_dir);
Take your simplest tests and move them, one by one, into the new test directory and keep running the Test::Aggregate
program. You'll find some tests will not run in a shared environment like this. You can either fix the tests or simply leave them in your regular test directory. See how this distribution's tests are organized for an example.
METHODS
runtests
my $test_dir = 'aggtests/';
Test::Aggregate->runtests($test_dir);
Attempts to aggregate all test programs in a given directory and run them at the same time.
If $Test::Aggregate::DUMP
is set, will attempt to use the value as a filename and print the code to it.
CAVEATS
Not all tests can be included with this technique. If you have Test::Class
tests, there is no need to run them with this. Otherwise:
__END__
and__DATA__
tokens.These won't work and the tests will call BAIL_OUT() if these tokens are seen.
BEGIN
andEND
blocks.Since all of the tests are aggregated together,
BEGIN
andEND
blocks will be for the scope of the entire set of aggregated tests.Syntax errors
Any syntax errors encountered will cause this program to BAIL_OUT(). This is why it's recommended that you move your tests into your new directory one at a time: it makes it easier to figure out which one has caused the problem.
no_plan
Unfortunately, due to how this works, the plan is always
no_plan
. IfTest::Builder
implements "deferred plans", we can get a bit more safety. See http://groups.google.com/group/perl.qa/browse_thread/thread/d58c49db734844f4/cd18996391acc601?#cd18996391acc601 for more information.
AUTHOR
Curtis Poe, <ovid at cpan.org>
BUGS
Please report any bugs or feature requests to bug-test-aggregate at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Aggregate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Test::Aggregate
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2007 Curtis Poe, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.