Forum Discussion

JeanL's avatar
JeanL
Contributor
13 years ago

OnStopTest Event and exception

Hi,



The manual says:



"



The OnStopTest event is not generated if the test is stopped right after it has begun. Also, the OnStopTest is not generated in Connected Applications.



In all other cases, the OnStopTest event is generated when the test run is finished. For instance, if --

- An exception occurred during the script execution.




"



For example I had the case where UBound() had faulty parameter which caused exception, and when unexpected exception occurred, I got popup about it and execution stopped there without executing the OnStopTest event where I do several things. And this is not happening right after the beginning of the test. Why test doesn't go to OnStopTest Event in this case?
  • But the popup that appears is error dialog created by TestComplete, how to handle that?



    And what if I have in this case error dialog turned off, then I don't get unexpected window, but exception still occurs.
  • Hi,


    In order for TestComplete to stop the test run when an exception occurs, follow the steps below:


    1. Add your test to the Test Items page of the project editor.

    2. In the Stop on Exception column, select Test Item.

    3. Disable the project's Error dialog option.

    4. Run the project. TestComplete will run the test. When an exception occurs, TestComplete will not display an error dialog and stop the test run.


    You can also create an OnStopTest event handler to perform the needed actions after the test run is stopped. TestComplete will perform these actions just once the exception occurs.

  • Yes, I already have OnStopTest event and I disabled Error dialog option.



    I put "mine" (test = Ubound(grfhgh)) which causes exception every time in the middle of one of my scripts and I ran the script 10 times. 3 out of 10 times TestComplete didn't execute the OnStopTest event. Why is that?



    Edit. I'm Using TestComplete 8.60.665.7, I have Windows 7 and used browser is IE9.
  • Hi,


    To help us reproduce the problem, could you please send us your project or the script you are using?

  • I finally had some time to study this problem little bit more and I was able to reproduce it in testproject. It seems that TestComplete goes to OnStopTest event everytime when exception occurs, but it doesn't execute it entirely. I created simple OnStopTest event like this:



    Sub GeneralEvents_OnStopTest(Sender)



      Log.Message "Message 0"

      Log.Message "Message 1"

      Log.Message "Message 2"

      Log.Message "Message 3"

      Log.Message "Message 4"

      Log.Message "Message 5"

      Log.Message "Message 6"

      Log.Message "Message 7"     

      Log.Message "Message 8"

      Log.Message "Message 9"



    End Sub



    And when exception (the same UBound error) occurred TestComplete went to this event, but almost never did it post all the 10 messages to the log after the Ubound error. It usually posted 2-3 lines but after that, nothing.



    Anyways, I will send the testsuite to you and you can examine this problem further more. I hope to hear some kind of resolution from you guys whether this problem is in TestComplete, in my computer (setup) or in testsuite (settings etc.) and how can I resolve this.

  • Hi Jean,



    Thank you for the sample project. We have received it and I will contact you once we have any results.