So often you open up a test suite and see 20 test programs starting
with something like this:
use Test::More tests => 23;
use Test::Differences;
use Test::Exception;
That's awfully repetitive and if you have a standard set of testing
tools, that gets annoying. Instead, I'd like to do something like
this:
use My::Tests tests => 20;
That would incorporate all of the above and look like this:
package My::Tests;
use Test::Custom qw(
Test::More
Test::Differences
Test::Exception
);
1;
Of course, you'd have to have importing facilities and "conditional"
loading:
package My::Tests;
use Test::Custom qw(
Test::More
Test::Differences
),
'Test::SomethingOrOther' => [ 'bulges_ok' ];
Test::Custom->add('Test::NoWarnings') if $some_condition;
1;
The question I'm trying to figure out is the best way to implement
this. I could have Test::Custom build something like this:
eval <<"END";
package $calling_package;
use Test::More @test_more_imports;
use Test::Exception @test_exception_imports;
use Test::Differences @test_exception_imports;
END
if ( my $error = $@ ) { ... }
However, I just *know* there are problems with this, but I can't think
for the life of me what they might be. Does that seem sane to folks?
Am I overlooking something blindingly obvious?
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/