A Sneak peek into PowerDebug for QTP
Research team at KnowledgeInbox has been working on a revolutionary product code named “PowerDebug”. This product has been under research for over 2 years now and is now on the verge of a Beta Release in Jan 2010. The product is aimed at adding better debugging and error handling capabilities to QTP. This is the first ever product of its kind.
With this article I would like to give you a small Sneak peek into features of PowerDebug
Enhanced Error Messages
'C:\Runtime.qfl Function Testing() eval "x = 2/0" End Function |
Msgbox "I am raising an error now" ExecuteFile "C:\Runtime.qfl" Call Testing |
There is a “Division by Zero” error in the Testing function. But since the library has been loaded at run-time, QTP will throw an error showing the error positing as the first line of the Action code. The error message raise by QTP is shown below
Now by enabling a small flag in the code for enhancing the error messages
Msgbox "I am raising an error now" ExecuteFile "C:\Runtime.qfl" PowerDebug.EnhancedErrors = True Call Testing |
QTP will now raise the same error with more details as shown below
With such enhanced error message it becomes obvious to spot on the hard to debug issues and locate their source. This also means that error messages that go into the QTP Test report now has the code stack dump as well.
Getting the current Function Name
It is impossible in QTP or VBScript to know in code which function is currently being executed. This information being available can help enhance your frameworks by easing the logging of function calls and also allowing to fetch any stored information related to the function
Function WhatIsMyName() Print "Your Name is - " & PowerDebug.FunctionName End Function Call WhatIsMyName |
OnError Function Handlers
QTP or VBScript has a limitation where once cannot execute a function in case an error occurs. This limits the way errors can be handled. But not anymore, PowerDebug allows you to set a function that will be called when an error occurs
PowerDebug.OnError = "PleaseCallMe" Function PleaseCallMe() PleaseCallMe = "Continue" Print "Thank you for calling me" Print "Some error occured - " & Err.Description End Function x = 2/0 Print "This message has been after the error has occured" |
The function being called needs to return the next action to be taken. The possible values are “continue”, “retry”, “abort” and none.
- If no value is returned in the function then after the function call the error is raised and the normal handling happens
- If “continue” is returned then execution continues to the next line
- If “abort” is returned then execution aborts
- If “retry” is returned then the statement is retried. This if done incorrectly can create a endless retries causing the code to be caught in vicious circle
Enhanced Error Information
PowerDebug also enhances the information available when an error occurs, the err object exposed by PowerDebug provides more information on error like stack dump, error line #, error code, function name where error occurred. The code below shows some these capabilities
PowerDebug.OnError = "Continue" x = 2/0 With PowerDebug Print "Number = " & .Err.Number Print "Method = " & .Err.MethodName Print "Time = " & .Err.Time Print "Stack = " & .Err.StackDump Print "Line No = " & .Err.LineNo Print "Description = " & .Err.Description Print "Source = " & .Err.Source Print "Code = " & .Err.Code End |
Assigning “Continue” to PowerDebug.OnError works same as using a “On Error Resume Next” and allows enhanced error information.
Note: Using “On Error Resume Next” would not enhance any error messages
Code Tracing
This function is currently under development, so there are no screenshots available. But this feature would show the code execution line by line and can help see what is going in background in the code. An ultimate features for those running execution their scripts using BPT or loading a lot of code at run-time which QTP doesn’t show any insight into.
The product will be launched in the first half of 2010 and will mark the beginning of an new era of enhanced frameworks built on error handling capabilities of PowerDebug
Have questions related to this article? Want to request a new article? Use our forums to post your questions
Viewed 839 times


(6)






Tags used -

































