This is a migrated thread and some comments may be shown as answers.

Run tests several time

3 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nazar
Top achievements
Rank 1
Nazar asked on 18 Nov 2013, 10:15 AM

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?

3 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 2
answered on 18 Nov 2013, 01:08 PM
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.
0
Cody
Telerik team
answered on 20 Nov 2013, 11:52 PM
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
0
Daniel
Top achievements
Rank 2
answered on 21 Nov 2013, 01:34 PM
Good suggestion Cody.  Something I will keep in mind for future steps.  Thanks!
Tags
General Discussions
Asked by
Nazar
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 2
Cody
Telerik team
Share this question
or