Intellipro     

Automating Test Automation                  Home Automation Articles Downloads QTP Gotchas Links Books Contact About Site Map

Error Handling in QTP

Error Button

Other people have written some really good articles on this.

The best I have found so far is this one by Dani Vainstein

To summarise the use of the 'Recovery Scenario' in QTP I am best quoting Theo Moore:

'...I can honestly say that they blow...and I mean goats...nickel a herd...'

(I'm not familiar with that saying, but I'm guessing it isn't complimentary).

As a general rule you should write all the error handling code yourself so that your tests can fail gracefully and enable your test suites to be fault-tolerant.

That old, but much touted example scenario of a printer running out of paper is a really bad example.

And how often does providing the option of 'retry' or 'skip' actually resolve anything?

So, how to write your own error handling? - first a short history lesson...

History

vbScript is based on VB (visual basic) which in turn is based on GW-Basic and QuickBasic

Basic used to use line numbers for flow control
i.e. you could have a Goto 100 to branch the code to line 100 in the program

(It was an undocumented feature of Visual Basic that it still supported line numbers
and that these could be used/displayed in the error handling).

Consequently the normal way to invoke error handling was 'On Error GoTo Xxx'
where 'xxx' could either be a specific line number or a line label
and the specified line had to be in the same procedure.

You would then put your error handling in the area following the line label.

Error handling was then turned off using the command 'On Error GoTo 0'.

This history explains the current way of turning off error handling!

Unfortunately, line labels and 'Goto' do not exist in vbScript.

This means that the ONLY way to fully implement your own error handling is to check the Error object status immediately after EVERY line of code!

NOBODY wants to do that

That's why people use the Recovery Scenario mechanism.

A New Approach

Years ago, when I was working on a large project using VB3 and around 30 developers, I wrote a handy tool to completely automate the addition of the error handling code to the vb source code.

I have now written a similar tool for QTP

This only works for script files NOT test files (but then most of your code should be in scripts).

Anyway, give it a try and let me know what you think.

You can find it here.


Copyright © 2011 Intellipro Services Ltd. All rights reserved                      Home About Privacy Policy Terms of use Contact Site Map






































































advanced advice agile answers application articles aut automated automating automation basics beginners browser button checkbox child childobjects click close code coding combo combobox consultant consultancy convention count createobject database delete descriptive download downloads dp edit editbox element enhancements error examples faq faqs file files filesystemobject fixes folder folders forum framework frameworks function functions generation generator getobject getroproperty gotchas group guide guru harness hewlett hp inputbox insert intellipro interview language library libraries link list listbox manifesto manual master name naming navigate object or packard page ping pro problem procedure procedures professional programming qtp query queries question questions quick quicktest radio refresh repository ross row rows samples script scripts scrum select server software specific sprint sql step stored strategy structure sub subroutine suite sync tables test testing text textbox title tool tools tsl tutorial update updates url vbscript web webedit webpage webradiogroup weblist whittaker wscript