Usage of "On error resume next" in keyword driven framework

753 views
Skip to first unread message

KRISHNA CHAITHANYA

unread,
Apr 24, 2012, 9:19:21 AM4/24/12
to mercu...@googlegroups.com
Hello All , 

Issue:

Can you help out detail explanation of error handling especially "On error resume next" in keyword driven framework.

Background info :

We were Using hybrid framework combination of keyword , data driven and function decomposition.

I had tried with recovery scenario's for some of pop windows in Win XP,2002 Sp3 with QTP 9.5(not able to handle them)due to tool limitation.

Then i had handle through the code and now , i want to handle expected & unexpected errors , i though of using "On error resume next".

Browsed many site for understanding & implementing "On error resume next". but not able to understand.

With limited knowledge i had implemented on error resume next in each keyword and then executed .it didn't worked as expected.

Actual Requirement :

If any keyword fails then it should come out of the testcase and it should log error number ,description and capture the screen shot & should save in specified location. 

Kindly help me out from this. Thanks in advance.
--
Thank you,

Krishna Chaithanya Chinthakayala (Kris)  | Mobile: +91 9885066684

Anish Pillai

unread,
Apr 24, 2012, 11:40:02 AM4/24/12
to mercu...@googlegroups.com
Hi Kris,

The basic requirement when you run a set of test cases in batch is that the execution should not halt in between. Even if a test case fails due to any reason, the framework should have the ability to leave that test case there and run the next one.

The main reason why our scripts get struck in between is due to some unexpected popup. These can be suppressed using On Error Resume Next. ie. when such an unxpected run time error occurs, On Error Resume Next instructs QTP to move to the next line. You can have some sort of handle that catches this exception.

One way to do this is to have the handler code at the end of every function you create.

Eg -


fnDivide()

Function fnDivide()

  On Error Resume Next
  i = 10/0 'exception that throws a popup message is suppressed due to use of on error resume next
 
  'some more code
  'some more code
  'some more code
  'some more code

  'Handle the exception
  If Err.Number <> 0 Then
     Reporter.ReportEvent micFail, "Message" , "Message"
     'more handler code...
'      better would be to create a recovery function and call it here
  End If

End Function




--
ar

suman ch

unread,
Apr 25, 2012, 1:28:11 AM4/25/12
to mercu...@googlegroups.com
Hi ,

ON ERROR RESUME NEXT will be used to handle expected errors(exception handling). You have to identify what part of your code may give error and put it that in ON ERROR RESUME NEXT block, if err.number > 0 then there is some error. Keep ON ERROR GOTO 0 at the end disable error handling.

Regards,
Suman Ch

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

KRISHNA CHAITHANYA

unread,
Apr 25, 2012, 5:22:53 AM4/25/12
to mercu...@googlegroups.com
Anish & Suman Thanks for info.

Can you gimme some idea about what the difference between Error handling & Exception handling ?

and then as i said I had tried with recovery scenario's for some of unexpected pop windows in Win XP,2002 Sp3 with QTP 9.5(not able to handle them)due to tool limitation.

then what would be solution for handling this unexpected errors ?

before asking you questions here is some info about our frame work ..

We were Using hybrid framework combination of keyword , data driven and function decomposition.

All keywords (Business specific functions ) are written in .VBS file , generic functions in .Qlf ,driver script in .Mts and test data ,execution status , test case flow etc in Keyword engine (Excel book).

I had handled most of the expected pops with code rather than this i wanted them to handle with "on error resume next".

My concerns ..

i had kept this "on error resume next" in beginning of script file and error catching statements at end of the script , it didn't work.

then i had kept "on error resume next" in each key word starting and try to catch error display info then it is not at all executing the test cases it is simply displaying all the test cases name and its corresponding keywords in the result file.

My basic requirement is ..

if any keyword fail then automatically we have to capture the screen shot and save according to the time stamps and it should come out with complete error info and then start next test cases till end. 

Kindly help me out this. 

Thanks , Kris.
9885066684
Reply all
Reply to author
Forward
0 new messages