I'd appreciate your thoughts (and hopefully solution) to an issue that i have with the execution status being reported by TD of my WR scripts. I've already spoken to Mercury support about but had no joy as to why it occurs or what the solution is.
Here goes...I use a return values in my WR scripts to identify errors and to exit the test (e.g. to determine if a window has appeared, i use rc = win_exists(window_name)). If rc has a value of anything other than E_OK i know there is a problem and fail the test using tl_step("test failed", 1, "test failed") and the command texit to stop the test. This error handling routine is stored in a separate compiled module as it is called by several other scripts
This works fine when running WR scripts directly from WR (log shows FAIL), however when i run my scripts from TD. If a script fails TD reports "NOT COMPLETED" as the test status.
Here is some simplified code which demonstrates what i am doing
COMPILED MODULE (test_include)
# Terminate the HIMFOS application
# Determine if we fail & exit the current test
if (test_status == "fail test")
tl_step("test failed", 1, "test failed");
} # ExitHIMFOS
Apologies for the long-winded explanation. Hopefully it makes sense. Does anyone have any ideas??
TExit should never be used in a compiled module, especially with TD, as TD runs the tests in the batch mode and when TExit is seen the test is stopped, not exited so the return to TD would be "Not Completed" You should use TReturn, as TReturn exits the module and returns control to the calling test. It also passes a failed value back to the calling test where you should evaluate the returned value and decide wether to continue or fail the test with a TExit.
Thanks for your reply. I did think about using "treturn" instead of "texit" (according to what it says in the manual and what you say, it seems like the perfect solution). The trouble is "treturn" can't be used inside a function (when you compile, WR reports "treturn statement cannot appear within a function").
Others must have come across this problem before, how is everyone else handling failed test??
Oops, sorry about that, I'd swear we've used it in the past. What about <TExit [expression]> and pass the pass/fail expression back to the calling test where the result is evaluated? Actually the best method is to pass back the pass/fail status with a variable and then evaluate it and use TExit if it fails.