示例#1
0
        /// <summary>
        /// Runs this instance after passing validation, executing tests in the passed assemblies/solution.
        /// </summary>
        /// <returns></returns>
        public TestResultDictionary Run()
        {
            //run validation first
            Validate();

            //start timer
            var timer = new Stopwatch();
            timer.Start();

            //set logging output
            SetupLogging();

            //set output logging type
            Logger.Instance.ConsoleOutputType = ConsoleOutputType;

            //create queue
            ResultQueue = new TestResultDictionary(this);

            //bind test result events
            if (OnTestResult != default(TestResultEventHandler))
            {
                ResultQueue.OnTestResult += OnTestResult;
            }

            //loop through all assemblies, running their tests
            RunAssemblies();

            //stop the timer
            timer.Stop();

            //if we have single/none line logging, post the failed test messages
            if (Logger.Instance.IsSingleOrNoLined && ResultQueue.FailedTestResults.Any())
            {
                WriteFailedResultsToConsole();
            }

            //create result file and write
            WriteResultsToFile();

            //write results and timer
            Logger.Instance.WriteDoubleLine(Environment.NewLine);
            Logger.Instance.WriteMessage(ResultQueue.ToTotalString());
            Logger.Instance.WriteMessage(string.Format("Total time: {0}", timer.Elapsed));
            Logger.Instance.WriteDoubleLine(postcede: Environment.NewLine);

            IsRunning = false;
            return ResultQueue;
        }