How to create a Test Suite in Perl's Test::Unit v0.25

If your Test Case is a package whose goal is to test all aspects of a particular class then a Test Suite is something which kicks off a collection of related Test Cases. As with most things in Perl’s Test::Unit it’s really easy to do and also terribly documented. So, without further ado… You need something to kick off all your tests:

use Test::Unit::HarnessUnit;
use My::Test::Suite::Package;

my $testrunner = Test::Unit::HarnessUnit->new();
$testrunner->start("My::Test::Suite::Package");

Next you need the test suite it’s going to kick off:

package My::Test::Suite::Package;
use base qw/Test::Unit::TestSuite/;

# returns an array of the fully qualified names of the TestCase
# based classes you wish to run.
sub include_tests() {
    return ('Some::Test::Case',
        'Some::Test::Case2',
        'Some::Test::Case3);
}

1;

That’s it. Happy testing.