Forum Discussion

mustafayol's avatar
mustafayol
Contributor
3 years ago

same kind of event handlers for different events

Hi, 

Here is the imaginary scenario that resembles the issue that I have in a simpler explanation.

1) I created a desktop test, it has Test1, Test2 and Test3. Each test case handles different tasks.

2) When there is an unexpected window that pops up at any of these tests, I want to be informed by email.

So I created 3 different event handlers as EventControl_Test1, EventControl_Test2 and EventControl_Test3.

3) Then for each event handler, I added the general events: OnUnexpectedWindow. 

Until here, you can see the explanation in picture 1.

4) After adding the general events: OnUnexpectedWindow, respective test scripts had the eventHandler functions at the bottom of the test scripts.

 

As a result, for each separate test case, I created a separate event handler (EventControl_Test1_OnUnexpectedWindow,EventControl_Test2_OnUnexpectedWindow, EventControl_Test3_OnUnexpectedWindow), which is expected to be triggered in case of having unexpected windows.

I added an email sending function into each eventHandler function. 

You can see the explanation in Picture 2. This picture is for test1 but, it is also the same for test2 and test3, only handlers and test cases are different. 

 

Expected result: When I run test1 and when I encounter an unexpected window, I would expect  "EventControl_Test1" to be triggered and the respective email to be sent.

 

Actual Result: When I run test 1 and encounter an unexpected window, all of the EventControl_OnUnexpectedWindow handlers are triggered.

I mean even if I have an unexpected window while running test1, unexpected window event handlers of test2 and test3 are also triggered.

The stranger part is, this happens even when I do only run test1, and get an unexpected window, event handlers of test2 and test3 are all triggered, then send emails. This can be seen in Picture 3.

 

Is this a bug, or should I make another assignment? Or is the way I try to implement it wrong?

 

 

Picture1:

 

 

Picture 2

 

 

Picture 3

 

 

 

  • Since it's all the same response, I would use one event handler for all three.  I think that will get you one response per test and only from the tests that are running.

     

    I don't believe that TestComplete understands that you mean those three event handlers to line up with the tests.  It is just seeing an unexpected window and oh look here are the events I need to do when that happens and you get three messages no matter what.

7 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Since it's all the same response, I would use one event handler for all three.  I think that will get you one response per test and only from the tests that are running.

     

    I don't believe that TestComplete understands that you mean those three event handlers to line up with the tests.  It is just seeing an unexpected window and oh look here are the events I need to do when that happens and you get three messages no matter what.

      • mustafayol's avatar
        mustafayol
        Contributor

        It is not a solution, but yes answer is enough for me, I will try to find another workaround, thank you Marsha,

         

        Regards

        Mustafa