in reply to Running a set of tests twice
You might want to look at Test::Class and the section on "Extending Test Classes by Inheritance".
For a more manual approach, what I've often found helpful when I feel like I'm needing identical tests is just creating my testing functions in a helper module that takes an object to be tested (or even just a class name) and a prefix for the test label.
# file: t/helper.pm package t::helper; @EXPORT = qw( run_all_tests ); use strict; use warnings; use base 'Exporter'; use Test::More; sub run_all_tests { my ($obj, $prefix) = @_; diag "Starting tests for $prefix"; isa_ok( $obj, "Parent::Class", "$prefix: object isa Parent::Class" + ); ok( $obj->true(), "$prefix: true() is true" ); # more tests ... } 1;
# file: t/001.t use Test::More 'no_plan'; use t::helper; my @cases = ( Parent::Class->new(), Sub::Class->new(), ); for my $o ( @objs ) { run_all_tests( $o, ref $o ); }
Does that do what you were looking for? Or did you mean something different by "comprehensive output"?
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|