Test::Class::Most
I'm really tired of boilerplate. In fact, I hate it so much that I can't stand when I write this:
package Some::Test::Class;
use strict;
use warnings;
use base 'My::Test::Class';
use Test::More;
use Test::Exception;
Of course, you already know about Test::Most and Modern::Perl, so you could reduce it to this:
package Some::Test::Class;
use base 'My::Test::Class';
use Modern::Perl;
use Test::Most;
But that's still boilerplate. So here's what I've just uploaded:
package Some::Test::Class;
use Test::Class::Most parent => 'My::Test::Class';
That gets you strict, warnings, all test functions from Test::Most and, if you have 5.10 or better, all the modern features of Modern::Perl. It (reluctantly) supports multiple inheritance (pass an arrayref of class names as the value to 'parent') and if you don't want the modern features, you can do this:
package Some::Test::Class;
use Test::Class::Most parent => 'My::Test::Class', feature => 0;
To create your own Test::Class base class (which inherits directly from Test::Class), just don't specify an import list:
package My::Test::Class;
use Test::Class::Most;
The documentation includes links to my Test::Class tutorials for those not familiar with it:
- Organizing your test suites
- Reusing test code
- Making Test::Class easier to use
- Test control methods
- Final tips and summary
Test::Class::Most is not quite as pretty as Piers Cawley's lovely Test::Class::Sugar, but it has far less magic. I think the docs are clear, but if they confuse you see the the Test::Class tests I ship with it for a good example. Hopefully it will make your test classes much more pleasant to write.
Ovid, thank you for the code.