http://www.perlmonks.org?node_id=496796


in reply to Re^2: too much testing?
in thread too much testing?

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