What you're looking for is Test::Class
.
You can make a test class for Foo::Bar
, which I would probably call Test::Foo::Bar
. This Perl module will use Test::Class
as its base class. But instead of testing Foo::Bar
directly, access it through a method:
sub class {'Foo::Bar'}
This allows us to override it later.
Then you make a new test class, Test::Foo::Bar::Baz
which inherits from Test::Foo::Bar
. By doing this, you've automatically inherited all the tests you wrote for the parent class. Of course you'll need to override class():
sub class {'Foo::Bar::Baz'}
Voila! You're now running all your tests from Test::Foo::Bar
on Foo::Bar::Baz
, and you're free to override or make new tests to your heart's content.
Chromatic has a thorough example on his blog: Resuing Test Code with Test::Class
And you're right about test harnesses already existing. A mixture of Test::Class
, Test::Harness
, and prove
should take care of your needs, and there's very little reason to write your own.