package Foo; ## BEGIN UNIT TESTING use Test::Unit; print "Testing Foo: "; create_suite(); run_suite(); print "\n\n"; sub test_new { my $foo = Foo->new(name => 'Bar', baz => "Quux"); # Test to make sure it was constructed correctly. assert($foo->get_name() eq 'Bar'); assert($foo->get_baz() eq 'Quux'); # My constructor should die if called with no args, check for that with this line: eval { my $foo = Foo->new() }; assert($@); } sub test_method_1 { my $foo = Foo->new(name => 'Bar', baz => 'foon'); assert($foo->gurglify(15)); assert($foo->gurgled_amount() == 15); }