Forum Discussion

chadm_1's avatar
chadm_1
New Contributor
14 years ago

Is it possible to debug on runtime error?

I was wondering if anyone could give me a definitive answer as to whether or not it SHOULD be possible to debug a script after a runtime error.



The easiest way of replicating what I mean is to write a few lines of code that forces a divide by 0:



Function TestDebug()

Dim intNum1, intNum2, dblResult



intNum1 = 5

intNum2 = 0



dblResult = intNum1 / intNum2



End Function





If I run this, it gives a VBScript runtime error popup.  However, this popup only has an OK button, which when clicked completely stops the script execution.  I need to know if there's any way to get TestComplete to allow you to debug from the current line that threw the error so you can figure out exactly why it had the error. 



I realize you can stop the test run, put a breakpoint on a line right before where the error occurred, and run to the breakpoint on a 2nd execution.  However, this is not always a viable option because in our systems there is a lot of non-user-entered data that effects our test cases that changes from run to run (stock prices, etc), so there's no guarantee the error will happen again on the next rerun.



In the project properties, on the Playback section, there is the "Error Dialog" checkbox.  The description for this checkbox states "If this option is enabled, TestComplete will ask whether to stop the test run on critical errors".  If this is unchecked and I run the example above it just stops execution without throwing the runtime exception popup.  The fact that it says "ask whether..." implies to me that it should somehow be possible to debug in these cases. 



Any advise/input would be appreciated.

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Is an error written to the test log?  If so, you should be able to double click on the line in the test log and it will take you straight to the guilty spot.
  • chadm_1's avatar
    chadm_1
    New Contributor
    I'm not sure actually.  A separate issue I'm trying to resolve is that TC crashes when I try to open a TC log.  But even if it did, that would only show you where in the code the error happened after the test run has been stopped wouldn't it?



    In a more realistic case of having a runtime error in our scripts, we would need to start digging into the objects/variables at runtime to figure out what ultimately caused the error to occur. 



    Having come from a QTP background, there is a "debug" button on runtime error popups that allows you to debug the error, and from there you can fully debug the error by viewing all of the objects/variables invovled.  Then, we can make necessary code changes after the run since we were able to nail down the cause. 



    That's specifically the type of debugging scenario I'm curious if it should be possible in TC.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    When I ran your code to do the divide by zero, I actually got text that says what unit and line number within that unit of code generated the error and that it is a divide by zero error.  When I click OK on that, I get another message that gives me the Microsoft VBScript runtime error screen telling me, again, it is a divide by zero error with the error location giving me precisely the file location, line number, and column number of the error.



    Additionally, in the background, the unit with the error in it is opened for me to see with the line causing the error highlighted in red.



    Do you not get these two screens or the highlight?



    As for the error dialog, I do not get that unless I'm running the full project or running a specific test item (for example, add a test item to the test item panel that links to that divide by zero function and run just it).  I can then, at that point, either say to proceed past the critical error or stop the project run.