Ejemplo n.º 1
0
        // The value of 'testName' should match that which was used when
        // registering the test in TestInventory.cs in the test app project.
        public TestSetupHelper(ICollection <string> testNames, TestSetupHelperOptions options = null, bool shouldRestrictInnerFrameSize = true)
        {
            if (options == null)
            {
                options = new TestSetupHelperOptions();
            }
            this.Options = options;

            // If a test crashes, it can take a little bit of time before we can
            // restart the app again especially if watson is collecting dumps. Adding a
            // delayed retry can help avoid the case where we might otherwise fail a slew of
            // tests that come after the one that crashes the app.
            var retryCount = 10;

            while (retryCount-- > 0)
            {
                var success = TestSingleRun(testNames, shouldRestrictInnerFrameSize);
                if (success)
                {
                    break; // no need to retry
                }
                else
                {
                    Log.Warning("Failed to setup test. pending retries: " + retryCount);
                    if (retryCount > 0)
                    {
                        Log.Comment("Waiting before retry...");
                        TestEnvironment.ShouldRestartApplication = true;
                        Task.Delay(5000);
                    }
                    else
                    {
                        Log.Error("Failed to set up test!");
                        try
                        {
                            DumpHelper.DumpFullContext();
                        }
                        catch (Exception e)
                        {
                            Log.Error("Also failed to dump context because of an exception: {0}", e.ToString());
                            throw;
                        }
                        throw new InvalidOperationException("All attempts to set up test failed.");
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public TestSetupHelper(string testName, TestSetupHelperOptions options = null)
     : this(new[] { testName }, options)
 {
 }