summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-11-19 12:34:35 -0700
committerGitHub <noreply@github.com>2016-11-19 12:34:35 -0700
commit33a5f443d31a250b9b956f9039daeea67faf6555 (patch)
tree6e81bae0d5c1a38d2881d19d6b48ff6eea95537d /Xamarin.Forms.Core.iOS.UITests
parentaf29ab93b9980677bd03ea414262c327f85042f7 (diff)
downloadxamarin-forms-33a5f443d31a250b9b956f9039daeea67faf6555.tar.gz
xamarin-forms-33a5f443d31a250b9b956f9039daeea67faf6555.tar.bz2
xamarin-forms-33a5f443d31a250b9b956f9039daeea67faf6555.zip
Adding some restart logic to the UI tests if navigation fails (#550)
Diffstat (limited to 'Xamarin.Forms.Core.iOS.UITests')
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs35
1 files changed, 34 insertions, 1 deletions
diff --git a/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs b/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs
index 78fa2e3d..1b64fbbc 100644
--- a/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs
+++ b/Xamarin.Forms.Core.iOS.UITests/BaseTestFixture.cs
@@ -63,7 +63,40 @@ namespace Xamarin.Forms.Core.UITests
protected virtual void FixtureSetup()
{
ResetApp();
- NavigateToGallery();
+
+ int maxAttempts = 2;
+ int attempts = 0;
+
+ while (attempts < maxAttempts)
+ {
+ attempts += 1;
+ try
+ {
+ NavigateToGallery();
+ return;
+ }
+ catch (Exception ex)
+ {
+ var debugMessage = $"NavigateToGallery failed: {ex}";
+
+ Debug.WriteLine(debugMessage);
+ Console.WriteLine(debugMessage);
+
+ if (attempts < maxAttempts)
+ {
+ // Something has failed and we're stuck in a place where we can't navigate
+ // to the test. Usually this is because we're getting network/HTTP errors
+ // communicating with the server on the device. So we'll try restarting the app.
+ CoreUITestsSetup.LaunchApp();
+ }
+ else
+ {
+ // But if it's still not working after [maxAttempts], we've got assume this is a legit
+ // problem that restarting won't fix
+ throw;
+ }
+ }
+ }
}
protected void ResetApp()