All of my modules are works in progress. I'm always adding new features, especially to HTML::Lint, so I want to make sure I always have valid test cases for those new features. I try to follow the principle of "write the test case first", but in case I don't, or I forget to update the MANIFEST, I've created the following test files.
For HTML::Lint, in the t/01.coverage.t file:
use_ok( 'HTML::Lint::Error' );
my @errors = keys %HTML::Lint::Error::errors;
isnt( scalar @errors, 0, 'There are at least some errors to be found.' );
for my $error ( @errors ) {
my $filename = "t/$error.t";
ok( -e $filename, "$filename exists" );
}
and in the new Carp::Assert::More, in the t/02.coverage.t:
use_ok( 'Carp::Assert::More' );
my @funcs = ( @Carp::Assert::More::EXPORT, @Carp::Assert::More::EXPORT_OK );
my %deduped;
$deduped{$_}++ for @funcs;
@funcs = sort keys %deduped;
isnt( scalar @funcs, 0, 'There are no function names!' );
for my $func ( @funcs ) {
my $filename = "t/$func.t";
ok( -e $filename, "$filename exists" );
}
In each case, the code tracks the features (possible error messages in HTML::Lint, or function names in Carp::Assert::More) and makes sure that there's an appropriate .t file that corresponds.
Re:I like it!
gav on 2002-08-10T05:15:08
Devel::GetSymbols might come in handy.Re:I like it!
ajtaylor on 2002-08-13T16:36:03
Thanks for the idea. It looks quite useful.