ExitActionIteration doesnot work if "On Error resume Next" is used. (527 Views)
Reply
Advisor
krAnand
Posts: 16
Registered: ‎08-22-2013
Message 1 of 3 (527 Views)
Accepted Solution

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

[ Edited ]

Hi, 

 

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?

 

SampleCode:
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

    ExitActionIteration
    Call FuncC

    On Error goto 0
End Function

Function funcC
    print "FUNC C CALLED"    
End Function

 

HP Expert
Ana_Noncheva
Posts: 245
Registered: ‎08-06-2013
Message 2 of 3 (506 Views)

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

Hello,

 

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.

 

Regards,

Ana

“HP Support
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution.”
Advisor
krAnand
Posts: 16
Registered: ‎08-22-2013
Message 3 of 3 (493 Views)

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

Thanks ana for your comments.

It's been a great pleasure with you.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.