Forum Discussion

lordneeko's avatar
lordneeko
New Contributor
13 years ago

Rerun failed test once

I was wondering if there is a builtin method of having TestComplete automatically rerun a test once if it produced a Failure.  Many times the failure is due to a bad timing or something, and while we continue working out the timing issues, the fact that a timing issue occured will still show up in the error log (because we'll see it failed once, and then passed.



Any tips?

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Nothing built in because the definition of "failure" is variable from user to user.  That's something that would be handled most likely from a Test Management software application.  For that matter, you would have to have a way of classifying types of failures to re-run.  Timing issues you would... issues where a checkpoint failed you might not.  That's something that would have to be user defined in some sort of code.
  • lordneeko's avatar
    lordneeko
    New Contributor
    ok so let's say that this is what i want



    if (test script that just ran reported an error (errcount>0)) and Run_count < 2 then

    rerun the test

    else continue on with the rest of the suite.





    This is the basic pseudocode, but i'm not sure were i would put it. Is this a valid set of code to go in an "onEvent" method?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    What test?  How is the test written?  Is it a granular test in a Keyword or single Script code function?  Or is it some sort of combination of multiple functions?  Are you using a data driven/table driven framework to define your tests or is everything procedural based?



    All these questions add varying degrees to what you're asking.  You could call it in an event, but you would have to have some way of passing to the event, either through a global variable or something, to indicate what you defines as "the test" that failed.  Depending upon the architecture of what you've constructed for your automation, an "OnErrorEvent" might not be the best place.  For that matter, is a OnLogWarning, a valid place for such a thing?  is a warning a failure?  Or are errors the only "failure" condition?



    As for run count, you would have to track that somewhere, too, because that's not a native item for many different kinds of test construction in TestComplete.  



    So.,... my best answer... it depends.  Again, there's nothing "native" to TestComplete to do that, it's something you would have to construct within your particular automation framework/architecture.



    In my case, the framework I've constructed, each "test" is read in from a set of CSV files as a list of steps.  I could wrap my iterative code in such a way that, if the any step in that list returns a "failed" status (basically a boolean "false" if a function fails to complete with a pre-determined indicator of success), to go back to the beginning of the loop and try again.  It would all be code and it would be a bit complex to make sure it runs in the framework so yes, it's possible to do what you're asking, but it all depends...
    • Lagencie's avatar
      Lagencie
      Frequent Contributor

      I know this post is old - but its exactly what I need.

       

      I dont really care which failure happened - it should rerun the test once if it fails, if it fails 2 times -> fail, if it passes the second time -> pass ... No matter which failure occurs or whatever happens and it should be something that works for each tests without having to do anything within the testcase itself.

       

      Isnt there something like the Test Items: Count .. so you can set it to count: 2 if failure occured count: 1 if it passes at first run?