Forum Discussion

chris-'s avatar
chris-
New Contributor
8 years ago

Threaded test execution

Hi,

 

I'm testing an application where exceptions are caught, then handled in a separate application with a more user-friendly bubble pop-up.  We have code that will detect the presence of a the exception bubble pop-up and take the appropriate action already.

 

However, we have a problem trying to run that check throughout our test.  An exception could occur at any point during testing, and may not have an obvious impact on the application, focus also remains with the application during the pop-up.

 

At the moment, the only way i can see to have this check run throughout is to literally call it after every step like this:

 

Step 1

 > Check

Step 2

 > Check

Step 3

 > Check

Step 4

 > Check

Step 5

 > Check

 

Which seems inefficient and wildly impractical to write.  The better option seems like it'd be to thread that checking process so that the execution/writing looks more like this:

Step 1

 > Thread

Step 2          Check (looping in thread)

Step 3          Check

Step 4          Check

Step 5          Check

 > Kill thread

 

But i can't see any way to do that in TestComplete, is it possible?  The Network Suite doesn't seem like it'd fit the purpose unfortunately, as a test running on one machine won't see the exception bubble generated by another machine.

 

Thanks,

Chris.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    If you want to have a function/routine running on an interval checking for the pop-up every few seconds, you could use a Timer object.  Check out https://support.smartbear.com/testcomplete/docs/scripting/timers.html for info.

    Note, however, that according to that document, if this pop-up is seen as an "unexpected window", the timer will not execute it's routine.

    So, that is actually another way of doing things.  There is an event handler for "OnUnexpectedWindow" as well as "OnOverlappingWindow".  you could treat that pop-up as one of these.  So, check out https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/unexpected-windows.html

    • chris-'s avatar
      chris-
      New Contributor

      Ah, thanks Robert, very useful!

       

      It seems like neither solution gives the flexibility of actual threaded execution (unexpected windows only triggers when the script performs actions, timers halt all test execution until the check is complete), but it's probably about as close as we're likely to get i think - i'll experiment with combinations of these two and see how it goes.

       

      Thanks for the help!

      Chris.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Well, by "halt" all execution, as long as your routine in your timer is pretty quick, it is relatively quick.  Keep your timer routine to a quick check of "does the window exist RIGHT NOW (WaitAliasChild with the timeout parameter set to 0)? If so, click a button" Fire that off every 10 seconds or so and you probably won't even notice that it's running.

        In any case, these are scripted tests using an interpreted language... there's no multi-threading.  Using the built in event handlers or using a Timer are probably the best you're going to get.