Context:
Say I have a few modules that inherit from each other (using old-school inheritance with base
and parent
, not Moose or similar). Foo::Bar
inherits Foo
, and Foo::Bar::Baz
inherits Foo::Bar
. All of these modules have test suites written with Test::More
. The test suite for a child class only tests the methods that it implements. Child classes do not necessarily override all methods in their parents, though they may add new methods that their parent does not have.
Question:
Is there some testing framework, technique, or Test::More
feature with which I can write tests that will not only test subclass-specific behavior, but will also then run test suites for any inherited behavior/parent classes as well? Basically, I'm looking for something that allows me to write tests for the unique/special behavior of a subclass, but will also test and make sure that the subclass behaves in tests the same way that its parent class(es) are expected to.
What I've tried:
I've written a very simple test harness with a generator method that builds an instance of a string-specified module and runs tests against it depending on what type of module was requested (there's a central hash that keeps track of subclass/superclass hierarchy), but this seems crude. I'm assuming that (like most things I need to do in Perl), someone else has already done this in a much more elegant and robust way.