Helper class used to summarize the result of a test run
예제 #1
0
        private void InitializeXmlFile(ITestResult result)
        {
            ResultSummary summaryResults = new ResultSummary(result);

            xmlWriter.WriteStartDocument();

            xmlWriter.WriteStartElement("assemblies");

            xmlWriter.WriteStartElement("assembly");

            xmlWriter.WriteAttributeString("name", result.FullName);
            AssemblyName assemblyName = AssemblyHelper.GetAssemblyName(Assembly.GetExecutingAssembly());

            xmlWriter.WriteAttributeString("environment", $"nunit-version: {assemblyName.Version}, clr-version: {Environment.Version}, os-version: {Environment.OSVersion}, platform: {Environment.OSVersion.Platform}, cwd: {Environment.CurrentDirectory}, machine-name: {Environment.MachineName}, user: {Environment.UserName}, user-domain: {Environment.UserDomainName}");
            xmlWriter.WriteAttributeString("test-framework", "nunitlite");
            xmlWriter.WriteAttributeString("run-date", XmlConvert.ToString(startTime, "yyyy-MM-dd"));
            xmlWriter.WriteAttributeString("run-time", XmlConvert.ToString(startTime, "HH:mm:ss"));

            xmlWriter.WriteAttributeString("total", summaryResults.TestCount.ToString());
            xmlWriter.WriteAttributeString("errors", summaryResults.ErrorCount.ToString());
            xmlWriter.WriteAttributeString("failed", summaryResults.FailureCount.ToString());
            xmlWriter.WriteAttributeString("skipped", summaryResults.SkipCount.ToString());

            // TODO: inconclusive? invalid?
            var passedCount = summaryResults.TestCount - summaryResults.FailureCount - summaryResults.SkipCount - summaryResults.NotRunCount;

            xmlWriter.WriteAttributeString("passed", passedCount.ToString());
        }
예제 #2
0
        /// <summary>
        /// Constructs an instance of ResultReporter
        /// </summary>
        /// <param name="result">The top-level result being reported</param>
        /// <param name="writer">A TextWriter to which the report is written</param>
        public ResultReporter(ITestResult result, ExtendedTextWriter writer)
        {
            this.result  = result;
            this._writer = writer;

            this.summary = new ResultSummary(this.result);
        }
예제 #3
0
        private void InitializeXmlFile(ITestResult result)
        {
            ResultSummary summary = new ResultSummary(result);

            xmlWriter.WriteStartDocument(false);
            xmlWriter.WriteComment("This file represents the results of running a test suite");

            xmlWriter.WriteStartElement("test-results");

            xmlWriter.WriteAttributeString("name", result.FullName);
            xmlWriter.WriteAttributeString("total", summary.TestCount.ToString());
            xmlWriter.WriteAttributeString("errors", summary.ErrorCount.ToString());
            xmlWriter.WriteAttributeString("failures", summary.FailureCount.ToString());
            var notRunTotal = summary.SkipCount + summary.FailureCount + summary.InvalidCount;

            xmlWriter.WriteAttributeString("not-run", notRunTotal.ToString());
            xmlWriter.WriteAttributeString("inconclusive", summary.InconclusiveCount.ToString());
            xmlWriter.WriteAttributeString("ignored", summary.IgnoreCount.ToString());
            xmlWriter.WriteAttributeString("skipped", summary.SkipCount.ToString());
            xmlWriter.WriteAttributeString("invalid", summary.InvalidCount.ToString());

            xmlWriter.WriteAttributeString("date", result.StartTime.ToString("yyyy-MM-dd"));
            xmlWriter.WriteAttributeString("time", result.StartTime.ToString("HH:mm:ss"));
            WriteEnvironment();
            WriteCultureInfo();
        }
예제 #4
0
        /// <summary>
        /// Constructs an instance of ResultReporter
        /// </summary>
        /// <param name="result">The top-level result being reported</param>
        /// <param name="writer">A TextWriter to which the report is written</param>
        public ResultReporter(ITestResult result, TextWriter writer)
        {
            this.result = result;
            this.writer = writer;

            this.summary = new ResultSummary(this.result);
        }
예제 #5
0
        /// <summary>
        /// Constructs an instance of ResultReporter
        /// </summary>
        /// <param name="result">The top-level result being reported</param>
        /// <param name="writer">A TextWriter to which the report is written</param>
        public ResultReporter(ITestResult result, ExtendedTextWriter writer)
        {
            _result = result;
            _writer = writer;

            _overallResult = result.ResultState.Status.ToString();
            if (_overallResult == "Skipped")
            {
                _overallResult = "Warning";
            }

            Summary = new ResultSummary(_result);
        }
예제 #6
0
 private void ReportResults(NUnit.Framework.Api.ITestResult result)
 {
     Summary = new ResultSummary(result);
     writer.WriteLine("{0} Tests : {1} Failures, {2} Errors, {3} Not Run", Summary.TestCount, Summary.FailureCount, Summary.ErrorCount, Summary.NotRunCount);
     if (Summary.FailureCount > 0 || Summary.ErrorCount > 0)
     {
         PrintErrorReport(result);
     }
     if (Summary.NotRunCount > 0)
     {
         PrintNotRunReport(result);
     }
 }
예제 #7
0
        private void ReportResults(TestResult result)
        {
            ResultSummary summary = new ResultSummary(result);

            writer.WriteLine("{0} Tests : {1} Errors, {2} Failures, {3} Not Run",
                             summary.TestCount, summary.ErrorCount, summary.FailureCount, summary.NotRunCount);

            if (summary.ErrorCount + summary.FailureCount > 0)
            {
                PrintErrorReport(result);
            }

            if (summary.NotRunCount > 0)
            {
                PrintNotRunReport(result);
            }
        }
예제 #8
0
        public void DisplaySummaryReport(ResultSummary summary)
        {
            var status = summary.ResultState.Status;

            var overallResult = status.ToString();

            if (overallResult == "Skipped")
            {
                overallResult = "Warning";
            }

            ColorStyle overallStyle = status == TestStatus.Passed
                ? ColorStyle.Pass
                : status == TestStatus.Failed
                    ? ColorStyle.Failure
                    : status == TestStatus.Skipped
                        ? ColorStyle.Warning
                        : ColorStyle.Output;

            if (_testCreatedOutput)
            {
                SkipLine();
            }

            WriteSectionHeader("Test Run Summary");
            WriteLabelLine("   Overall result: ", overallResult, overallStyle);

            WriteSummaryCount("   Tests run: ", summary.RunCount);
            WriteSummaryCount(", Passed: ", summary.PassCount);
            WriteSummaryCount(", Errors: ", summary.ErrorCount, ColorStyle.Error);
            WriteSummaryCount(", Failures: ", summary.FailureCount, ColorStyle.Failure);
            WriteSummaryCount(", Inconclusive: ", summary.InconclusiveCount);
            _outWriter.WriteLine();

            WriteSummaryCount("     Not run: ", summary.NotRunCount);
            WriteSummaryCount(", Invalid: ", summary.InvalidCount, ColorStyle.Error);
            WriteSummaryCount(", Ignored: ", summary.IgnoreCount, ColorStyle.Warning);
            WriteSummaryCount(", Explicit: ", summary.ExplicitCount);
            WriteSummaryCount(", Skipped: ", summary.SkipCount);
            _outWriter.WriteLine();

            WriteLabelLine("  Start time: ", summary.StartTime.ToString("u"));
            WriteLabelLine("    End time: ", summary.EndTime.ToString("u"));
            WriteLabelLine("    Duration: ", summary.Duration.ToString("0.000") + " seconds");
            SkipLine();
        }
예제 #9
0
        private void ReportResults(NUnit.Framework.Api.ITestResult result)
        {
            ResultSummary resultSummary = new ResultSummary(result);

            writer.WriteLine("{0} Tests : {1} Failures, {2} Errors, {3} Not Run", resultSummary.TestCount, resultSummary.FailureCount, resultSummary.ErrorCount, resultSummary.NotRunCount);
            if (resultSummary.FailureCount > 0 || resultSummary.ErrorCount > 0)
            {
                PrintErrorReport(result);
            }
            if (resultSummary.NotRunCount > 0)
            {
                PrintNotRunReport(result);
            }
            if (commandLineOptions.Full)
            {
                PrintFullReport(result);
            }
        }
예제 #10
0
        private bool ReportResults(TestResult result)
        {
            bool success = true;
            var  summary = new ResultSummary(result);

            writer.WriteLine("\r\n\r\n{0} Tests : {1} Errors, {2} Failures, {3} Not Run\r\n",
                             summary.TestCount, summary.ErrorCount, summary.FailureCount, summary.NotRunCount);

            if (summary.ErrorCount + summary.FailureCount > 0)
            {
                PrintErrorReport(result);
                success = false;
            }

            if (summary.NotRunCount > 0)
            {
                PrintNotRunReport(result);
            }

            return(success);
        }
예제 #11
0
        public void ReportResults(ITestResult result)
        {
            Summary = new ResultSummary(result);

            _textUI.DisplaySummaryReport(Summary);

            if (result.ResultState.Status == TestStatus.Failed)
            {
                _textUI.DisplayErrorsAndFailuresReport(result);
            }

            if (Summary.SkipCount + Summary.IgnoreCount > 0)
            {
                _textUI.DisplayNotRunReport(result);
            }

#if FULL
            if (_options.Full)
            {
                _textUI.PrintFullReport(_result);
            }
#endif
        }
예제 #12
0
        public void ReportResults(ITestResult result)
        {
            Summary = new ResultSummary(result);

            _textUI.DisplaySummaryReport(Summary);

            if (result.ResultState.Status == TestStatus.Failed)
                _textUI.DisplayErrorsAndFailuresReport(result);

            if (Summary.SkipCount + Summary.IgnoreCount > 0)
                _textUI.DisplayNotRunReport(result);

#if FULL
            if (_options.Full)
                _textUI.PrintFullReport(_result);
#endif
        }
예제 #13
0
        private void InitializeXmlFile(ITestResult result)
        {
            ResultSummary summaryResults = new ResultSummary(result);

            xmlWriter.WriteStartDocument(false);
            xmlWriter.WriteComment("This file represents the results of running a test suite");

            xmlWriter.WriteStartElement("test-results");

            xmlWriter.WriteAttributeString("name", result.FullName);
            xmlWriter.WriteAttributeString("total", summaryResults.TestCount.ToString());
            xmlWriter.WriteAttributeString("errors", summaryResults.ErrorCount.ToString());
            xmlWriter.WriteAttributeString("failures", summaryResults.FailureCount.ToString());
            xmlWriter.WriteAttributeString("not-run", summaryResults.NotRunCount.ToString());
            xmlWriter.WriteAttributeString("inconclusive", summaryResults.InconclusiveCount.ToString());
            xmlWriter.WriteAttributeString("ignored", summaryResults.IgnoreCount.ToString());
            xmlWriter.WriteAttributeString("skipped", summaryResults.SkipCount.ToString());
            xmlWriter.WriteAttributeString("invalid", summaryResults.InvalidCount.ToString());

            xmlWriter.WriteAttributeString("date", XmlConvert.ToString(startTime, "yyyy-MM-dd"));
            xmlWriter.WriteAttributeString("time", XmlConvert.ToString(startTime, "HH:mm:ss"));
            WriteEnvironment();
            WriteCultureInfo();
        }
예제 #14
0
        /// <summary>
        /// Reports the results.
        /// </summary>
        /// <param name="result">The result.</param>
        private void ReportResults( ITestResult result )
        {
            Summary = new ResultSummary(result);

            writer.WriteLine("{0} Tests : {1} Failures, {2} Errors, {3} Not Run",
                Summary.TestCount, Summary.FailureCount, Summary.ErrorCount, Summary.NotRunCount);

            if (Summary.FailureCount > 0 || Summary.ErrorCount > 0)
                PrintErrorReport(result);

            if (Summary.NotRunCount > 0)
                PrintNotRunReport(result);
        }
예제 #15
0
        private bool ReportResults( TestResult result )
        {
            bool success = true;
            var summary = new ResultSummary(result);

            writer.WriteLine("\r\n\r\n{0} Tests : {1} Errors, {2} Failures, {3} Not Run\r\n",
                summary.TestCount, summary.ErrorCount, summary.FailureCount, summary.NotRunCount);

            if (summary.ErrorCount + summary.FailureCount > 0)
            {
                PrintErrorReport(result);
                success = false;
            }

            if (summary.NotRunCount > 0) PrintNotRunReport(result);

            return success;
        }
예제 #16
0
파일: TextUI.cs 프로젝트: roboticai/nunit
        public void DisplaySummaryReport(ResultSummary summary)
        {
            var status = summary.ResultState.Status;

            var overallResult = status.ToString();
            if (overallResult == "Skipped")
                overallResult = "Warning";

            ColorStyle overallStyle = status == TestStatus.Passed
                ? ColorStyle.Pass
                : status == TestStatus.Failed
                    ? ColorStyle.Failure
                    : status == TestStatus.Skipped
                        ? ColorStyle.Warning
                        : ColorStyle.Output;

            if (_testCreatedOutput)
                SkipLine();

            WriteSectionHeader("Test Run Summary");
            WriteLabelLine("   Overall result: ", overallResult, overallStyle);

            WriteSummaryCount("   Tests run: ", summary.RunCount);
            WriteSummaryCount(", Passed: ", summary.PassCount);
            WriteSummaryCount(", Errors: ", summary.ErrorCount, ColorStyle.Error);
            WriteSummaryCount(", Failures: ", summary.FailureCount, ColorStyle.Failure);
            WriteSummaryCount(", Inconclusive: ", summary.InconclusiveCount);
            _outWriter.WriteLine();

            WriteSummaryCount("     Not run: ", summary.NotRunCount);
            WriteSummaryCount(", Invalid: ", summary.InvalidCount, ColorStyle.Error);
            WriteSummaryCount(", Ignored: ", summary.IgnoreCount, ColorStyle.Warning);
            WriteSummaryCount(", Explicit: ", summary.ExplicitCount);
            WriteSummaryCount(", Skipped: ", summary.SkipCount);
            _outWriter.WriteLine();

            WriteLabelLine("  Start time: ", summary.StartTime.ToString("u"));
            WriteLabelLine("    End time: ", summary.EndTime.ToString("u"));
            WriteLabelLine("    Duration: ", summary.Duration.ToString("0.000") + " seconds");
            SkipLine();
        }
예제 #17
0
        /// <summary>
        /// Reports the results.
        /// </summary>
        /// <param name="result">The result.</param>
        private void ReportResults( ITestResult result )
        {
            ResultSummary summary = new ResultSummary(result);

            writer.WriteLine("{0} Tests : {1} Failures, {2} Errors, {3} Not Run",
                summary.TestCount, summary.FailureCount, summary.ErrorCount, summary.NotRunCount);

            if (summary.FailureCount > 0 || summary.ErrorCount > 0)
                PrintErrorReport(result);

            if (summary.NotRunCount > 0)
                PrintNotRunReport(result);

            if (commandLineOptions.Full)
                PrintFullReport(result);
        }