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.


In reply to Re: Running a set of tests twice by xdg
in thread Running a set of tests twice by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.