ExitActionIteration doesnot work if "On Error resume Next" is used.
[ Edited ]



Today i experienced that "ExitActionIteration" does not work in the function when "On Error resume Next" is used.


(This only happens when functions are kept in a library files. If function is written in the calling action then 'ExitActionIteration' is working fine).  


We are usually keep our functions in library files, where in some conditions we need to exit the ActionIterations, but in this case we are unable to do that and our tests keep running even in failure scenarios.



Currently i am using UFT11.52, but i believe that this issue should persists in previous versions of QTP also.



 Please tell if this is an expected behaviour? If yes then please let us know how can we exit the iteration from a function where "On error Resume next" is used (and the function is written in external/library file) ?



Note: I could find the solution where i am using "ON error goto 0" before "ExitActionIteation" , and whoa it worked :-) .

Is there any second thought on this?


Call FuncA   'Keep this code in the  calling Actions


'Following Functions should be kept in a library files.
Function funcA
    print "FUNC A CALLED"
    Call Funcb
End Function

Function funcB

    On Error Resume Next
    print "FUNC B CALLED"

     'On Error goto 0

    Call FuncC

    On Error goto 0
End Function

Function funcC
    print "FUNC C CALLED"    
End Function


HPE Expert
Re: ExitActionIteration doesnot work if "On Error resume Next" is used.



This is happening because statements like

ExitAction, ExitActionIteration, ExitTest, ExitTestIteretion raise (internal) run-time errors in QTP/UFT.

Those run-time errors are catched by the On Error Resume Next statement, which enables the error handling, and therefore execution continues with next statement - in this case, the Call funcC line. This is the expected behavior of On Error Resume Next statement and you "turn it off" with the On Error Go To 0 statement.




“HP Support
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.”
Re: ExitActionIteration doesnot work if "On Error resume Next" is used.
Thanks ana for your comments.

It's been a great pleasure with you.