Forum Discussion
- AlexKarasChampion Level 3
Hi,
Not sure, but maybe Runner.Stop / Runner.Halt method(s) will help...
- Judychen2020Occasional Contributor
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 Functionand 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
- AlexKarasChampion Level 3
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.
Related Content
- 10 years ago
- 12 years ago
- 12 years ago
Recent Discussions
- 3 hours ago
- 13 hours ago