[Israel.pm] Alternative for catching return value

David Baird davidlbaird at gmail.com
Mon Nov 14 03:26:00 PST 2005


Our test scripts are filled with this kind of construction:

$ret = $sysUnderTest->someAction($foo, $bar, 'foo', 'bar');
die "System Under Test failed = $testEnv::return_dscr[$ret]\n"
    unless $ret == $testEnv::ACTION_SUCCESS;

or sometimes like this:

$ret = $sysUnderTest->Stop();
if (($ret != $testEnv::CMD_INVALID_FOR_STATE) &&
    ($ret != $testEnv::ACTION_SUCCESS) ) {

    $sysUnderTest->DESTROY;
    die "Stop failed = $testEnv::return_dscr[$ret]\n";
}

I think that the DESTROY method is called, because it has to return
the system under test to a neutral state, and perhaps there is some
misunderstanding on when the DESTROY of all objects will get called.

Could anyone come up with cleaner code which doesn't require defining
$ret, but still allows the debugger to catch the return value before
the test script dies?

Thank you,
David




More information about the Perl mailing list