Forum Discussion

m_essaid's avatar
m_essaid
Valued Contributor
7 years ago

tests result depends on the speed of execution

hi,

 

it's probably a message in bottle, but :

 

i'm testing a delphi application, and I have a bug that occurs systematicaly while running TC or TE.

but... when I try to do it "step by step" (debug) or manually, I'm not longer able to reproduce it.

 

Any help would be much appreciated,

 

Mehdi

5 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Yup, typical timing issue... and your subject actually explains it all.  The automation attempts to run at "full speed" so, when it goes to perform an action, it attempts to do so as soon as possible without being "smart" about the application.  So, your bug might actually be due to TestComplete attempting to do something against your AUT before it's ready to...

     

    There is an option in Tools -> Current Project Properties -> Playback called "Auto-Wait Timeout".  This is how long TestComplete will wait for an object before it says that it cannot find the object... increasing this value MAY help your situation.

     

    However, a better way is that, in your automation, build in specific checks to "wait" for the application to get to a particular state before the automation moves on.  This is using methods like WaitWindow, WaitAliasChild, WaitChild, etc.  These will tell TC to wait up to an indicated time for the designated object to resolve.  If it resolves before that time, the method will return the object.  If it doesn't, the method will return a "stub" object with the Exists property set to "false".  Add checks in your code to use these "Wait" methods to check to see if something exists before your automation moves forward.

     

    You can also use "WaitProperty" to wait for the property of an object to change to a particular value.  WaitProperty operates on the same principle in that it will wait a maximum time.  If it returns before that time, WaitProperty returns "true".  If not, it returns "false".  So you can use this also to build in custom "wait" methodology.

    • cunderw's avatar
      cunderw
      Community Hero

      To second that, if you could provide more information about what is actually happening vs what you expect to happen, your mappings / code snippets or screenshots of your KWT someone around here can probably point you in a good direction to start figuring out what exactly is the issue in your situation. 

  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Hello guys,

     

    Thank you for your answers,

     

    Finaly I made it run by adding a one second delay between the lines that causes issues.

    It works perfectly.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      m_essaid wrote:

      Hello guys,

       

      Thank you for your answers,

       

      Finaly I made it run by adding a one second delay between the lines that causes issues.

      It works perfectly.


      Glad that works.  Just note that I find using hardcoded delays to be a problem.  What if you run your tests one day and 1 second is no longer long enough?

       

      That's why the "Wait" methods  mentioned are better.  You can set a maximum wait time, say 10 seconds.  If the object returns in 1 second, that's all you're wait.  But it will also account for situations where it may take 2 or 3 seconds.  I'd look into finding a way of implementing those wait functions to make your tests more flexible with regards to performance delays.

      • m_essaid's avatar
        m_essaid
        Valued Contributor

        Hey Robert,

         

        I'm not sure that the wait method will work, I think that the VCL component is already available.

        I think it's due to our access layer. We built a new access layer for our products and I test both old and new programs. Only thoses that work on the new data access layer make the tests fails.

        The VCL component, in both cases, are available.

         

        But... you may be right. When I'll adapt other tests I'll try some wait functions.