Example #1
0
        public static async Task FinishTestAsync(string testName, TestOutcome outcome, string message = null, string filename = null, string stdOut = null, bool printFailuresOnly = false)
        {
            var endTime = DateTimeOffset.Now.Ticks;

            TimeSpan duration;
            long     startTime;

            if (TestStartTimes.TryGetValue(testName, out startTime))
            {
                duration = new TimeSpan(endTime - startTime);
                TestStartTimes.Remove(testName);
            }
            else
            {
                duration = TimeSpan.Zero;
            }

            if (null == filename)
            {
                TestStartFilename.TryGetValue(testName, out filename);
                TestStartFilename.Remove(testName);
            }

            if (!printFailuresOnly || outcome != TestOutcome.Passed)
            {
                FancyConsole.Write("Test {0} complete.", testName);
                switch (outcome)
                {
                case TestOutcome.Failed:
                    FancyConsole.Write(ConsoleColor.Red, " Failed: {0}", message);
                    break;

                case TestOutcome.Passed:
                    FancyConsole.Write(ConsoleColor.Green, " Passed: {0}", message);
                    break;

                default:
                    FancyConsole.Write(" {0}: {1}", outcome, message);
                    break;
                }
                FancyConsole.WriteLine(" duration: {0}", duration);
            }

            await BuildWorkerApi.RecordTestAsync(testName, TestFrameworkName, outcome : outcome, durationInMilliseconds : (long)duration.TotalMilliseconds, errorMessage : message, filename : filename, stdOut : stdOut);
        }
Example #2
0
        public void PrintToConsole(bool addNewLine = true)
        {
            if (addNewLine)
            {
                FancyConsole.WriteLine();
                FancyConsole.Write("Runs completed. ");
            }

            const string percentCompleteFormat = "{0:0.00}% passed";

            FancyConsole.Write(
                this.PercentSuccessful == 100.0 ? FancyConsole.ConsoleSuccessColor : FancyConsole.ConsoleWarningColor,
                percentCompleteFormat,
                this.PercentSuccessful);

            if (this.FailureCount > 0 || this.WarningCount > 0)
            {
                FancyConsole.Write(" (");
                if (this.FailureCount > 0)
                {
                    FancyConsole.Write(FancyConsole.ConsoleErrorColor, "{0} errors", this.FailureCount);
                }
                if (this.WarningCount > 0 && this.FailureCount > 0)
                {
                    FancyConsole.Write(", ");
                }
                if (this.WarningCount > 0)
                {
                    FancyConsole.Write(FancyConsole.ConsoleWarningColor, "{0} warnings", this.WarningCount);
                }
                if ((this.WarningCount > 0 || this.FailureCount > 0) && this.SuccessCount > 0)
                {
                    FancyConsole.Write(", ");
                }
                if (this.SuccessCount > 0)
                {
                    FancyConsole.Write(FancyConsole.ConsoleSuccessColor, "{0} successful", this.SuccessCount);
                }
                FancyConsole.Write(")");
            }
            FancyConsole.WriteLine();
        }
Example #3
0
        public static void StartTest(string testName, string filename = null, bool skipPrintingHeader = false)
        {
            if (!skipPrintingHeader)
            {
                FancyConsole.WriteLine();
                FancyConsole.Write(FancyConsole.ConsoleHeaderColor, "Starting test: ");
                FancyConsole.Write(FancyConsole.ConsoleDefaultColor, testName);
            }

            if (null != filename)
            {
                if (!skipPrintingHeader)
                {
                    FancyConsole.Write(" [{0}]", filename);
                }
                TestStartFilename[testName] = filename;
            }
            if (!skipPrintingHeader)
            {
                FancyConsole.WriteLine();
            }

            TestStartTimes[testName] = DateTimeOffset.Now.Ticks;
        }