Run tests several time

4 posts, 0 answers
  1. Nazar
    Nazar avatar
    3 posts
    Member since:
    Dec 2012

    Posted 18 Nov 2013 Link to this post

    Hello,

    Can I make my tests run second time if it was failed for the first? For example, I have some functionality (e.g. Reports generated by API) and sometimes it does not work well (We have developers license and only limit # of calls can be made in some period of time), because of that my tests failed. I need to rerun them once again to make it passed. The idea is next: if test failed, it should be rerun from the beginning and if it would failed second time it should be indicated that test actually failed. Can I do this in some way?

  2. Daniel
    Daniel avatar
    13 posts
    Member since:
    Aug 2013

    Posted 18 Nov 2013 Link to this post

    Not sure if you are using test lists, or just tests, but you can use code behind to utilize OnAfterTestCompleted(), OnAfterTestListCompleted(), and/or OnStepFailure(): http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/execution-extensions.aspx - http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/execute-custom-scripts-before-after-test.aspx

    Check the test/step result for a fail, increment a counter (also check), and rerun your test.  If it fails again and your counter is over 1, fail with whatever message.

    Just a thought.
  3. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 20 Nov 2013 Link to this post

    Hello Nazar,

    We do not have any built-in, out of the box, feature to automatically re-run failed tests. Daniel's suggestion is pretty good. It might be easier to use a coded step to run your test and check the returned result, like this:
    try
    {
        this.ExecuteTest("myrealtest.tstest");
    }
    catch (Exception)
    {
        this.ExecuteTest("myrealtest.tstest");
    }

    If the test fails the first time control will be sent to the catch block and the test will automatically be run once more. If it fails again, the test runner will catch the exception and log the failed test. If the second attempt passes, the parent test will be set to Passed.


    Regards,
    Cody
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  4. Daniel
    Daniel avatar
    13 posts
    Member since:
    Aug 2013

    Posted 21 Nov 2013 Link to this post

    Good suggestion Cody.  Something I will keep in mind for future steps.  Thanks!
Back to Top