зеркало из
1
0
Форкнуть 0

added example of retry tests that eventually passes after timeouts

This commit is contained in:
Lukasz Zasada 2019-10-28 11:55:41 +01:00
Родитель 1a457ab47e
Коммит 2e7921334f
1 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -14,7 +14,8 @@ namespace TimeoutRetryAttributeExample
{ "RetryIsFiredDueToTimeout", 0 },
{ "RetryIsNotFiredDueToTimeout", 0 },
{ "RetryIsNotFiredDueToFailedAssertion", 0 },
{ "RetryIsNotFiredDueToException", 0 }
{ "RetryIsNotFiredDueToException", 0 },
{ "RetryIsFiredDueToTimeoutAndLimitNotReached", 0 }
};
// This test should execute 3 times and fail due to reached retry number limit
@ -58,5 +59,24 @@ namespace TimeoutRetryAttributeExample
Thread.Sleep(3000); // Wait more than MaxTime threshold
throw new Exception("Exception thrown"); // Throw exception
}
// This test should execute 3 times and fail 2 times due to reached retry number limit, then pass on the 3 run
[Test]
[MaxTime(2000)]
[TimeoutRetry(3)]
public void RetryIsFiredDueToTimeoutAndLimitNotReached()
{
TestContext.Out.WriteLine($"Running test for the {++retryCount["RetryIsFiredDueToTimeoutAndLimitNotReached"]} time");
TestContext.Out.WriteLine(retryCount["RetryIsFiredDueToTimeoutAndLimitNotReached"]);
if (retryCount["RetryIsFiredDueToTimeoutAndLimitNotReached"] < 3) // For 1 & 2 retry force timeout
{
Thread.Sleep(3000); // Wait more than MaxTime threshold
}
else
{
Thread.Sleep(1000); // Wait less than MaxTime threshold
}
Assert.True(true); // Add valid assertion
}
}
}