on 11/4/02 2:37 am, Curt Sampson at [EMAIL PROTECTED] wrote:

> On Tue, 9 Apr 2002, Michael G Schwern wrote:
> 
>>> I'm not sure exactly what the purpose of this is; your test will
>>> still fail if it dies even when not in a lives_ok block, right?
>> 
>> It'll fail and take the whole rest of the test program with it.  Some
>> testing systems like to abort the test script on failure.  Perl's
>> doesn't.
> 
> I'm not entirely sure I buy this, since the framework seems perfectly
> happy to tell me that something is wrong whether I complete all
> the tests in a script or not. But it's hardly a point worth arguing.
[snip]

Arguing anyway.... just for the sake of it :-)

My motivation was testing code that threw a lot of exceptions to signify
error conditions... so you had variations on things like:

my @test_cases = (
    [1,2,3] => [3,2,1],
    ["foo"] => ["oof"],
);

while (@test_cases) {
    my ($test_args, $test_results) = (shift @test_cases, shift @test_cases);
    my @results;
    lives_ok {@results = $foo->method(@$test_args) }
            "method(@$test_args) succeeded";
    is_deeply(\@results, $test_results,
            "method(@$test_args) = (@$test_results)");
};

The sequence of tests was stateless --- one test failing didn't invalidate
the other test cases. Running them all rather than exiting the test script
after a single failure seems to be a Good Thing.

It helped with my debugging anyway ;-)

Cheers,

Adrian
--
Adrian Howard  <[EMAIL PROTECTED]>
phone: 01929 550720  fax: 0870 131 3033  http://www.quietstars.com/


Reply via email to