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

Restart test

2 Answers 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 2
Andrei asked on 19 Apr 2012, 07:28 AM
Hi.

I have an test method:
[TestMethod]
[DataSource("")]
public void TestMeth()
{
try
{
//do something
}
catch(Exception ex)
{
Assert.Fail(ex.ToString());
}
}

The problem is: How I can to run this test again (max 3 times) when I get the exception? 

Is in telerik testing framework something to restart the test?





2 Answers, 1 is accepted

Sort by
0
Accepted
Anthony
Telerik team
answered on 23 Apr 2012, 04:15 PM
Hello Andrei,

There isn't anything specific to restart the test through the Framework, however you can easily encapsulate the desired code in a subroutine and call it as many times as desired within your existing test method. Here's an example:

[TestMethod]
public void Bing()
{
    ActiveBrowser.NavigateTo("http://www.bing.com");
 
    string i = "xImages";
    HtmlAnchor a = Find.ByExpression<HtmlAnchor>("textcontent=" + i);
    a.Click();
}
 
[TestMethod]
public void RestartTest()
{
    Manager.LaunchNewBrowser();
 
    try
    {
        Bing();
    }
    catch (Exception ex)
    {
        Log.WriteLine(ex.ToString());
 
        try
        {
            Bing();
        }
        catch (Exception ex2)
        {
            Log.WriteLine(ex2.ToString());
        }
    }
}


Greetings,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrei
Top achievements
Rank 2
answered on 26 Apr 2012, 07:34 AM
Thank you, I'll try...
Tags
General Discussions
Asked by
Andrei
Top achievements
Rank 2
Answers by
Anthony
Telerik team
Andrei
Top achievements
Rank 2
Share this question
or