コード例 #1
0
        // Until we get more of our memory leak issues worked out, restart the app
        // after a specified number of tests so we don't get bogged down in GC
        public void EnsureMemory()
        {
            s_testsrun += 1;

            if (s_testsrun >= ConsecutiveTestLimit)
            {
                s_testsrun = 0;

                CoreUITestsSetup.LaunchApp();

                FixtureSetup();
            }
        }
コード例 #2
0
ファイル: BaseTestFixture.cs プロジェクト: terrajobst/maui
        protected virtual void FixtureSetup()
        {
            ResetApp();

            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);
                    App.AttachScreenshotToTestContext(TestContext.CurrentContext?.Test?.FullName ?? "NavigateToGalleryFailed");

                    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;
                    }
                }
            }
        }