Forum Discussion
Thanks for your nice help. But it seems the runner.stop does not help.
The script is as below:
Function gettime()
Err.Clear
On Error Resume Next
i=1
while i<100
BuiltIn.Delay(1000)
if Err.Number<>0 Then
Log.Error Err.Description
Runner.Stop(CurrentTestOnly=True)
'Else
'Log.Message(" no error")
end If
i = i+1
wend
End Function
and I tried to use this function as below. I set a timeout for the project Save Result File to 1 min. But the whole test executed for 100s. And it seems the Runner.stop() does not help. Do you have any good advice?
Thanks
-Judy
Hi Judy,
> I set a timeout for the project Save Result File to 1 min.
Could you clarify what exact setting you have set to 1 minute?
Notes as for your code:
-- On Error Resume Next at the beginning of a function is extremely not recommended approach in VBScript because it obscures all possible problems. Error handling in VBScript is miles away from been convenient and the recommended sequence is like this:
On Error Resume Next
<code that might fail with runtime error>
iErr = Err.Number
IF(iErr <> 0) Then
strErrDescr = Err.Description
On Error GoTo 0
...
End IF
On Error GoTo 0
...
The reason for the above code is that Err object is internally (re)set after every executed line of code and thus one must store the state of the Err object *immediately* after execution of the line that might fail and then continue to work not with the Err object itself, but with the saved 'copy' of it.
-- if Err.Number<>0 Then
I see nothing in your code that might fail during runtime with *runtime* error and thus it is expected for me that your code never enters this IF block and thus Runner.Stop() is not called.
- Judychen20204 years agoOccasional Contributor
Hi AlexKaras:
Thanks for your nice help. I am sorry for describing the case not clear.
I set the timeout to 1 min for the Save Result File in the column named Timeout, min. When running the project, we can see the error "The execution timeout has expired. " in the log. But as you said, the Err.Number didn't change. Then we didn't get into the if condition.
- AlexKaras4 years agoChampion Level 3
Hi,
So, if I got you right, the behavior that you observe is correct, expected and is as following:
-- Test Item that exceeded Timeout set for it posts an error to test log and continues to run. This Test Item is not stopped because TestComplete does not stop test item that timed-out but just generates the OnTimeout event as documented. You may implement the handler for the OnTimeout event and stop test item (or the whole test run) if you need;
-- Next Test Item is started to be executed because the On Error setting for the timed-out Test Item is set to 'Continue running' value.
Is the above scenario correct?
Related Content
- 10 years ago
- 12 years ago
- 12 years ago
Recent Discussions
- 11 hours ago
- 7 days ago
- 10 days ago