示例#1
0
        private static bool ExecuteRunner(ITestRunner runner)
        {
            bool allTestsPassed = false;

            try
            {
                ResultsSummary summary                 = new ResultsSummary();
                int            prevFailedTestCount     = Int32.MaxValue;
                int            consecutiveFailureCount = 0;

                for (int runCount = 1; runCount < MAX_TEST_RUNS; runCount++)
                {
                    summary = runner.RunTests(summary.FailedTestNames);
                    Console.WriteLine("====== TestWrapper Run Attempt {0} =====", runCount);
                    Console.WriteLine(runner.ToString());
                    Console.WriteLine(summary);
                    Console.WriteLine("=======================");

                    var anyRan = summary.Passed > 0 || summary.Failed > 0;
                    if (!anyRan)
                    {
                        break;
                    }

                    allTestsPassed = summary.Failed == 0;
                    if (allTestsPassed)
                    {
                        break;
                    }

                    if (summary.Failed < prevFailedTestCount)
                    {
                        prevFailedTestCount     = summary.Failed;
                        consecutiveFailureCount = 0;
                    }
                    else if (consecutiveFailureCount < MAX_CONSECUTIVE_FAILURE)
                    {
                        consecutiveFailureCount++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occurred running tests:\n {0}", e.ToString());
                allTestsPassed = false;
            }

            return(allTestsPassed);
        }
示例#2
0
        private static bool ExecuteRunner(ITestRunner runner)
        {
            bool allTestsPassed = false;
            try
            {
                ResultsSummary summary = new ResultsSummary();
                int prevFailedTestCount = Int32.MaxValue;
                int consecutiveFailureCount = 0;
                
                for(int runCount = 1; runCount < MAX_TEST_RUNS; runCount++)
                {
                    summary = runner.RunTests(summary.FailedTestNames);
                    Console.WriteLine("====== TestWrapper Run Attempt {0} =====", runCount);
                    Console.WriteLine(runner.ToString());
                    Console.WriteLine(summary);
                    Console.WriteLine("=======================");

                    allTestsPassed = summary.Failed == 0;
                    if (allTestsPassed)
                    {
                        break;
                    }

                    if (summary.Failed < prevFailedTestCount)
                    {
                        prevFailedTestCount = summary.Failed;
                        consecutiveFailureCount = 0;
                    }
                    else if (consecutiveFailureCount < MAX_CONSECUTIVE_FAILURE)
                    {
                        consecutiveFailureCount++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            catch(Exception e)
            {
                Console.WriteLine("Exception occurred running tests:\n {0}", e.ToString());
                allTestsPassed = false;
            }

            return allTestsPassed;
        }