Matthew Astley (mc...@us...) wrote:
> On Wed, Apr 25, 2001 at 08:59:50PM +0100, Adam Spiers wrote:
> > Any thoughts on my proposed redesign of TestSuites? In case you
> > missed it, it was posted on March 7th, subject "TestSuite inheritance
> > and runner state"
> >
> > I proposed that we ditch this
> >
> > package My::TestSuites::Foo;
> >
> > sub suite {
> > my $class = shift;
> >
> > my $suite = Test::Unit::TestSuite->empty_new('name of suite');
> >
> > use My::TestSuites::Bar;
> > $suite->add_test(My::TestSuites::Bar->suite());
> >
> > use My::TestSuites::Baz;
> > $suite->add_test(My::TestSuites::Baz->suite());
> >
> > return $suite;
> > }
> >
> > in favour of
> >
> > package My::TestSuites::Foo;
> > use base qw(Test::Unit::TestSuite);
> >
> > sub name { 'name of suite' }
> > sub subsuites { qw(My::TestSuites::Bar My::TestSuites::Baz) }
> >
> > which is a hell of a lot easier to read, write, and implement the
> > framework for. It also means that My::TestSuites::Bar really ISA
> > TestSuite. It never used to be, which seems rather ridiculous.
>
> You're right, it's much better. Except, can we keep either the suite()
> method or have a call to new() instead please? I do some stuff at
> suite creation time. I could do it before starting the tests, but not
> if the tests are started with the (Tk)?TestRunner.pl provided with
> Perlunit.
Couldn't you do it by overriding new() in your suite?
> Test::Unit::Suite instead of Test::Unit::TestSuite would make a lot of
> sense, and shouldn't break too much stuff since it only occurs at the
> top-ish levels.
>
> Presumably there'd be defaults
> T:U::Suite::name { return ref(shift()) }
> T:U::Suite::subsuites { () }
> ?
Yes.
> Maybe we should have a client-side changelog? Listing things you'll
> need to do to your test code when you upgrade to the next release.
> Seems like a lot of effort though.
Aye, losing backwards compatibility is a concern here. Maybe we can
keep it with something like
if ($classname->can('suite')) {
...
}
elsif ($classname->can('new')) {
...
}
else {
die "uhoh";
}
Without thinking about it too carefully, this default might be
sensible too:
T::U::Suite::suite { $_[0] }
Sounds OK?
|