Beispiel #1
0
        protected void WriteError(string failureName, IFailureInformation failureInfo)
        {
            lock (consoleLock)
            {
                Program.SetConsoleForegroundColor(ConsoleColor.Red);
                Console.Error.WriteLine("   [{0}] {1}", failureName, Escape(failureInfo.ExceptionTypes[0]));
                Program.SetConsoleForegroundColor(ConsoleColor.Gray);
                Console.Error.WriteLine("      {0}", Escape(ExceptionUtility.CombineMessages(failureInfo)));

                WriteStackTrace(ExceptionUtility.CombineStackTraces(failureInfo));
            }
        }
Beispiel #2
0
        protected override bool Visit(ITestSkipped testSkipped)
        {
            lock (consoleLock)
            {
                // TODO: Thread-safe way to figure out the default foreground color
                Program.SetConsoleForegroundColor(ConsoleColor.Yellow);
                Console.Error.WriteLine("   {0} [SKIP]", Escape(testSkipped.Test.DisplayName));
                Program.SetConsoleForegroundColor(ConsoleColor.Gray);
                Console.Error.WriteLine("      {0}", Escape(testSkipped.Reason));
            }

            return(base.Visit(testSkipped));
        }
Beispiel #3
0
        protected override bool Visit(ITestFailed testFailed)
        {
            lock (consoleLock)
            {
                // TODO: Thread-safe way to figure out the default foreground color

                Program.SetConsoleForegroundColor(ConsoleColor.Red);
                Console.Error.WriteLine("   {0} [FAIL]", Escape(testFailed.Test.DisplayName));
                Program.SetConsoleForegroundColor(ConsoleColor.Gray);
                Console.Error.WriteLine("      {0}", ExceptionUtility.CombineMessages(testFailed).Replace(Environment.NewLine, Environment.NewLine + "      "));

                WriteStackTrace(ExceptionUtility.CombineStackTraces(testFailed));
            }

            return(base.Visit(testFailed));
        }
Beispiel #4
0
        void WriteStackTrace(string stackTrace)
        {
            if (String.IsNullOrWhiteSpace(stackTrace))
            {
                return;
            }

            Program.SetConsoleForegroundColor(ConsoleColor.DarkGray);
            Console.Error.WriteLine("      Stack Trace:");

            Program.SetConsoleForegroundColor(ConsoleColor.Gray);
            foreach (var stackFrame in stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None))
            {
                Console.Error.WriteLine("         {0}", StackFrameTransformer.TransformFrame(stackFrame, defaultDirectory));
            }
        }