Forum Discussion

Sariali's avatar
Sariali
Contributor
14 years ago

catch access violation

hi!



the program (test.exe) that tc tests shows a message dialog "access violation at address 0x0030393.."



meanwhile the tests continues, though it makes no sense to do this.



a good idea would be to recognize this special dialog with the textcontent "access violation at" and to stop TC / TE.



but how can i write such an exception-handler for an external program?



the alternative would be to catch exception in text.exe and send a message to TC / TE to stop 

or write a log that is polled by TC/TE ... but threading or timer are not possible there.







sincerly

necip sariali 
  • leahey's avatar
    leahey
    Occasional Contributor
    I've found that if I imagine my TestComplete scripts as a sort of "idiot" user, my test scripts are more robust.

    For instance, in the case of your AV message dialog, TestComplete is continuing to execute whatever automated actions it's been instructed; if those actions are non-visual (i.e. not interacting with the GUI), then TC doesn't detect that anything is out of sorts because it's not "looking" at the screen.

    If, however, your automation attempts to access the UI under test that lies beneath the message dialog in the Z-order, TC will then notice a problem in the form of an "unexpected window". TC provides several ways to handle error messages or other unexepected or "overlapping" windows. See the help topic "Handling Unexpected Windows" for more information.



    TestComplete cannot by default assume that you want to stop your test run just because there is an exception thrown in your application; there are (admittedly unfavorable) cases where a TC developer might wish the script to continue running after an AV; perhaps to see how the application under test handles the AV.



    You should probably create a set of Unexpected Window handling scripts for if your UI scripts encounter the message. It's likely that TC is trying to handle the unexpected AV message in its default, optimistic way, through timeouts, waiting for the window to go away, etc.



    In any case, you might also examine the help topic "Tracing Exceptions, Crashes and Freezes in Tested Applications".
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I've found that if I imagine my TestComplete scripts as a sort of "idiot" user, my test scripts are more robust.




    An EXCELLENT reminder for anyone doing test automation... the test automation is only as smart as the person writing it and will only do, explicitly, what you tell it to do.  There's only so much the automation environment (TestComplete in our case) can do before it starts interfering with creating robust tests.





  • Thank you Robert! 





    I looked in the directions of your advices 

    and found for my perposes 

    the "stop execution" - option 

    in the topic "On unexpected window" 










  • bad news... 

    "stop execution" option doesn't work

    for the info-dlg when my exe crashes.





    ok, i'll use tc as a simulation of an user

    and not for debugging my sourcecode :)
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The "OnUnexpectedWindow" event is triggered, IIRC, only if there is a window that is interfering with operations... much like the OnOverlappingWindow event.  So, again, if there are script steps that are running that are not trying to interact with the screen components, OnUnexpectedWindow may not fire.