-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tests): Ensure that UI tests are retried under more conditions
Tests are now retried on Setup/TearDown failures, Timeout and unhandled exceptions
- Loading branch information
1 parent
70f756b
commit 35e40d4
Showing
4 changed files
with
209 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/SamplesApp/SamplesApp.UITests/TestFramework/TestFrameworkTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace SamplesApp.UITests.TestFramework | ||
{ | ||
public partial class RetryTests | ||
{ | ||
static int When_Retry_On_Timeout_Count = 0; | ||
|
||
[Test] | ||
[AutoRetry] | ||
[Timeout(500)] | ||
public void When_Retry_On_Timeout() | ||
{ | ||
Console.WriteLine($"Draw_polyline2: {++When_Retry_On_Timeout_Count}"); | ||
if (When_Retry_On_Timeout_Count < 3) | ||
{ | ||
System.Threading.Thread.Sleep(1000); | ||
} | ||
} | ||
|
||
static int When_Retry_On_Unhandled_Exception_Count = 0; | ||
|
||
[Test] | ||
[AutoRetry] | ||
public void When_Retry_On_Unhandled_Exception() | ||
{ | ||
Console.WriteLine($"Draw_polyline2 {++When_Retry_On_Unhandled_Exception_Count}"); | ||
|
||
if (When_Retry_On_Unhandled_Exception_Count < 3) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
|
||
public partial class RetrySetup | ||
{ | ||
static int Setup_Count = 0; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
Console.WriteLine($"Setup: {++Setup_Count}"); | ||
|
||
if (Setup_Count < 3) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
[Test] | ||
[AutoRetry] | ||
public void When_Success() | ||
{ | ||
Console.WriteLine($"When_Success: {++Setup_Count}"); | ||
} | ||
} | ||
|
||
public partial class RetryTearDown | ||
{ | ||
static int TearDown_Count = 0; | ||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
Console.WriteLine($"TearDown: {++TearDown_Count}"); | ||
|
||
if (TearDown_Count < 3) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
[Test] | ||
[AutoRetry] | ||
public void When_Success() | ||
{ | ||
Console.WriteLine($"When_Success: {++TearDown_Count}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters