in reply to Re: Writing code using Test::More -- how to fail within subs?
in thread Writing code using Test::More -- how to fail within subs?
My code ends in an ok...() type statement, so if it reaches the end the tryit wrapper doesn't need to do anything. But if there is an exception, then the wrapper issues the NOT OK line. So, I don't get two tests out on success or one on failure like you seem to be illustrating re 'no_plan'.sub tryit (&$) { my ($code, $label)= @_; eval { &$code }; if ($@) { my $error= $@; # remember that in case fail() changes it. fail $label; diag "$label fails:", $error; } }
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Writing code using Test::More -- how to fail within subs?
by adrianh (Chancellor) on Feb 09, 2003 at 10:12 UTC |