On Fri, Jun 25, 2004 at 02:18:49PM -0500, Andy Lester wrote:
> On Fri, Jun 25, 2004 at 04:51:29PM +0100, Fergal Daly ([EMAIL PROTECTED]) wrote:
> > > * I never have to type repetitive tests like
> > > 
> > >   isa_ok Foo->new(), 'Foo'
> > > 
> > > again because it's handled by a base class that all my test classes 
> > > inherit from.
> 
> Repetition is good.  I feel very strongly that you should be checking
> your constructor results in every single test, and checked against
> literals, not variables.
> 
> my $foo = My::Foo->new();
> isa_ok( $foo, 'My::Foo' );
> # and then use it.
> #
> # Later on...
> my $foo = My::Foo->new( bar => 14, bat => \$wango );
> isa_ok( $foo, 'My::Foo' );
> 
> The more checks you have, the better.  Sure, the first isa_ok
> technically "covers" the constructor, but why not check after EVERY
> constructor?  The 2nd example is really an entirely different test.

@_ solves that.

sub constructor_ok
{
        my $class = shift;
        isa_ok($class->new(@_), $class);
}

I don't think xUnit style makes it any easier to run the same test with many
different inputs,

F

Reply via email to