in reply to too much testing?

Without adding a module, people generally put croaky code inside an eval:
eval { my $hashref = $foo->getDetails( PARAM_ONE => 1234); }; like $@, /missing PARAM_TWO/, "detect missing param 2";
If you want a more elegant version, see Test::Exception. But keep in mind that because that's a CPAN module, not everyone may have it installed.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: too much testing?
by geektron (Curate) on Sep 30, 2005 at 19:19 UTC
    i was going to look at Test::Exception as another way of doing it. (i admin the box, so i can install what i want.)

    the "standard" eval method came to mind also, but not using like with it. as always, There's More ....

      A comon pattern I find in my testing code is

      my @dieings; my @warnings; my $rc; eval { local $SIG{__WARN__} = sub {push @warnings, @_}; local $SIG{__DIE__ } = sub {push @dieings , @_}; $rc = $obj->method(@params); } is(@warnings, $expectedWarningCount, 'correct number of warnings raise +d'); like(shift(@warnings), qr/expected pattern of first warning/, 'first w +arning message correct'); like(shift(@warnings), qr/expected pattern of second warning/, 'second + warning message correct'); ... is(@dieings, $expectedDeathCount, 'correct number of deaths raised'); like(shift(@dieings), qr/expected pattern of first death/, 'first deat +h message correct'); ... is($rc, $expectReturnValue, 'method returned required value'); # or, if method returns an object isa_ok($rc, 'Expect::Class', 'received expected class'); ...

      ...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

        that's an interesting way of handling it.

        funny thing is, people seem to be gravitating to the part about catching $SIG{DIE} and not even noticing the title, or part of the real "meditation" ... though i guess not explicitly commenting on it is a commentary in itself.

        being the novice tester, i really am wondering when 'enough is enough' ...