Forum Discussion

Kate's avatar
Kate
Contributor
8 years ago

Need to rerun a test in case of certain error

I am testing a desktop app. Sometimes it sticks in 'connecting' state. If it stays in this 'connecting' state for more that 1 min I break the test execution.  

Is there a way to make TestComplete rerun the test which got this 'connecting' issue and continue the test run?

All my tests start with restarting the app so that may help.

8 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not exactly a re-run, but I would write a loop at the beginning of every test case to perform the following steps

     

    1) Check to see if we are connecting

    2) Wait to see if the connecting status goes away within a minute

    3) If it doesn't go away, kill the application and restart the application

    4) If it does go away, continue with the test

    5) loop 2-4 in a while loop checking each time through the loop.  I'd put a counter in the loop condition as well to limit it that, if it retries more than a certain number of times, mark the test case as failed and move to the next.

    Just as a side note... if the application is getting caught in a "connecting" state and it's not an artifact of the test automation, I'd raise a bug to my developers to let them know.  Personally, I'd rather not write test automation to work around bugs but let the test automation report bugs. You've found a bug with your automation... it did what it was supposed to do.  It's up to the developers to fix it. :)  Just my $0.02 US and, in this economy, that might not be worth a lot.

    • Kate's avatar
      Kate
      Contributor

      Unfortunately, it is not as straigtforward as it appeared to you...

       

      It is not a developers' issue. They are aware of it. And the issue is not stable in arising. Physical machine does not face it. Win 10 virtual machine faces it rarely... But Win7 and Win8 VMs - that happens a lot.

       

      The issue does not appear in the beginning of a test only. It may appear after any step that results in changing connection status. Many steps may have been performed prior to that. 

      So simple restarting the app does not work here. I need to start the test from the beginning. And continue the suite.

       

       

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        There's not a native way within TestComplete to say "rerun a test" because nothing in testcomplete can necessarily be strictly defined as "this is a specific test".  Keyword tests can be combined and called from each other, scripts the same.  So, to say "re run this" is something that would have to be handled in some sort of code.

         

        I don't know the architecture of how your test project is constructed so I can't say EXACTLY how to do it for you.  However, for me, what I would have is some sort of structure wrapped around every ACTUAL test case to detect success/failure and then act accordingly.  Additionally, since this is a common problem for your environment, I'd build into every test case a return value that would indicate pass or fail and, if failed, WHY it failed.  Then, within the wrapper structure, I'd put in code that, if it detects a failure, check the fail reason.  If it failed because of this connection problem, kill the app and loop back to the beginning of the test case.  Perhaps this detection process is something that is in a try/catch logic built into every test rather than some sort of calling wrapper, but that's the way I would handle it.