private void OutputLogStreamContents(StructuredStream stream)
            {
                string contents = string.Concat("*** ", stream.Name, " ***\n", stream.ToString(), "\n");

                // ReSharper formats the TaskExplain contents only when the task result is of a particular value.
                // It will render it in a colored box based on the result code.
                // Unfortunately it can't really capture the richness of Gallio outcomes right now.
                switch (stream.Name)
                {
                case MarkupStreamNames.ConsoleError:
                    Output(FacadeTaskOutputType.StandardError, contents);
                    break;

                case MarkupStreamNames.DebugTrace:
                    Output(FacadeTaskOutputType.DebugTrace, contents);
                    break;

                case MarkupStreamNames.Warnings:
                    pendingWarnings = contents;
                    break;

                case MarkupStreamNames.Failures:
                    pendingFailures = contents;
                    break;

                default:
                    Output(FacadeTaskOutputType.StandardOutput, contents);
                    break;
                }
            }
        protected static void AssertLogDoesNotContain(TestStepRun run, string expectedOutput, string streamName)
        {
            if (run == null)
            {
                throw new ArgumentNullException("run");
            }

            StructuredStream stream = run.TestLog.GetStream(streamName);

            Assert.DoesNotContain((stream == null) ? String.Empty : stream.ToString(), expectedOutput);
        }
        protected static void AssertLogLike(TestStepRun run, string expectedOutputPattern, string streamName)
        {
            if (run == null)
            {
                throw new ArgumentNullException("run");
            }

            StructuredStream stream = run.TestLog.GetStream(streamName);
            string           log    = (stream == null) ? String.Empty : stream.ToString();

            Assert.Like(log, expectedOutputPattern);
        }
Beispiel #4
0
        public static void AreEqual(StructuredStream expected, StructuredStream actual)
        {
            if (expected == null)
            {
                Assert.IsNull(actual);
                return;
            }

            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.ToString(), actual.ToString());

            // FIXME: not precise
        }
        public void ToStringPrintsTheBody()
        {
            StructuredStream stream = new StructuredStream("name")
            {
                Body = new BodyTag()
                {
                    Contents =
                    {
                        new TextTag("text")
                    }
                }
            };

            Assert.AreEqual("text", stream.ToString());
        }
Beispiel #6
0
        private void LogTest(TestStepFinishedEventArgs e)
        {
            // A TestResult with State == TestState.Passed won't be displayed in the
            // output window (TD.NET just diplays "[TestName] passed" in the status bar.
            // Since that can be harder to notice, and also is lost when the following
            // test finishes, we print a message in the output window so the user can
            // progressively see if the tests are passing or failing.
            if (e.TestStepRun.Result.Outcome.Status == TestStatus.Passed)
            {
                testListener.WriteLine(String.Format(Resources.TDNetLogMonitor_TestCasePassed,
                                                     e.TestStepRun.Step.FullName), FacadeCategory.Info);
            }

            // Inform TD.NET what happened
            FacadeTestResult result = new FacadeTestResult();

            result.Name     = e.TestStepRun.Step.FullName;
            result.TimeSpan = e.TestStepRun.Result.Duration;
            // result.TestRunner = "Gallio"; // note: can crash in older versions of TD.Net with MissingFieldException

            // It's important to set the stack trace here so the user can double-click in the
            // output window to go the faulting line
            StructuredStream failureStream = e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Failures);

            if (failureStream != null)
            {
                result.StackTrace = failureStream.ToString();
            }

            StructuredStream warningStream = e.TestStepRun.TestLog.GetStream(MarkupStreamNames.Warnings);

            if (warningStream != null)
            {
                result.Message = warningStream.ToString();
            }

            // TD.NET will automatically count the number of passed, ignored and failed tests
            // provided we call the TestFinished method with the right State
            result.State = GetTestState(e.TestStepRun.Result.Outcome.Status);

            testListener.TestFinished(result);
        }
        public void WriteToReproducesTheBodyOfTheStream()
        {
            StructuredStream stream = new StructuredStream("name")
            {
                Body = new BodyTag()
                {
                    Contents =
                    {
                        new TextTag("text")
                    }
                }
            };

            StructuredTextWriter writer = new StructuredTextWriter();

            stream.WriteTo(writer);
            writer.Close();

            Assert.AreEqual(stream.ToString(), writer.ToString());
        }
        /// <summary>
        /// Returns the log of the specified test step run.
        /// </summary>
        /// <param name="run">The test step run.</param>
        /// <param name="streamName">The name of log stream.</param>
        /// <returns>The log text or an empty string.</returns>
        protected static string GetLog(TestStepRun run, string streamName)
        {
            StructuredStream stream = run.TestLog.GetStream(streamName);

            return((stream == null) ? String.Empty : stream.ToString());
        }
Beispiel #9
0
        private static string FormatStream(TestStepRun testStepRun, string streamName)
        {
            StructuredStream stream = testStepRun.TestLog.GetStream(streamName);

            return(stream != null?stream.ToString() : @"");
        }