Example #1
0
        public void Visit(TestCaseResult caseResult)
        {
            xmlWriter.WriteStartElement("test-case");
            xmlWriter.WriteAttributeString("name", caseResult.Name);

            if (caseResult.Description != null)
            {
                xmlWriter.WriteAttributeString("description", caseResult.Description);
            }

            xmlWriter.WriteAttributeString("executed", caseResult.Executed.ToString());
            if (caseResult.Executed)
            {
                xmlWriter.WriteAttributeString("success", caseResult.IsSuccess.ToString());

                xmlWriter.WriteAttributeString("time", caseResult.Time.ToString("#####0.000", NumberFormatInfo.InvariantInfo));

                xmlWriter.WriteAttributeString("asserts", caseResult.AssertCount.ToString());
                WriteCategories(caseResult);
                WriteProperties(caseResult);
                if (caseResult.IsFailure)
                {
                    if (caseResult.IsFailure)
                    {
                        xmlWriter.WriteStartElement("failure");
                    }
                    else
                    {
                        xmlWriter.WriteStartElement("error");
                    }

                    xmlWriter.WriteStartElement("message");
                    xmlWriter.WriteCData(EncodeCData(caseResult.Message));
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("stack-trace");
                    if (caseResult.StackTrace != null)
                    {
                        xmlWriter.WriteCData(EncodeCData(StackTraceFilter.Filter(caseResult.StackTrace)));
                    }
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteEndElement();
                }
            }
            else
            {
                WriteCategories(caseResult);
//				WriteProperties(caseResult);
                xmlWriter.WriteStartElement("reason");
                xmlWriter.WriteStartElement("message");
                xmlWriter.WriteCData(caseResult.Message);
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteEndElement();
        }
Example #2
0
        private void WriteFailureElement(TestResult result)
        {
            xmlWriter.WriteStartElement("failure");

            xmlWriter.WriteStartElement("message");
            WriteCData(result.Message);
            xmlWriter.WriteEndElement();

            xmlWriter.WriteStartElement("stack-trace");
            if (result.StackTrace != null)
            {
                WriteCData(StackTraceFilter.Filter(result.StackTrace));
            }
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
        }
Example #3
0
        public void Visit(TestSuiteResult suiteResult)
        {
            xmlWriter.WriteStartElement("test-suite");
            xmlWriter.WriteAttributeString("name", suiteResult.Name);
            if (suiteResult.Description != null)
            {
                xmlWriter.WriteAttributeString("description", suiteResult.Description);
            }

            xmlWriter.WriteAttributeString("success", suiteResult.IsSuccess.ToString());
            xmlWriter.WriteAttributeString("time", suiteResult.Time.ToString("#####0.000", NumberFormatInfo.InvariantInfo));
            xmlWriter.WriteAttributeString("asserts", suiteResult.AssertCount.ToString());

            WriteCategories(suiteResult);
            WriteProperties(suiteResult);

            if (suiteResult.IsFailure && suiteResult.FailureSite == FailureSite.SetUp)
            {
                xmlWriter.WriteStartElement("failure");

                xmlWriter.WriteStartElement("message");
                xmlWriter.WriteCData(EncodeCData(suiteResult.Message));
                xmlWriter.WriteEndElement();

                xmlWriter.WriteStartElement("stack-trace");
                if (suiteResult.StackTrace != null)
                {
                    xmlWriter.WriteCData(EncodeCData(StackTraceFilter.Filter(suiteResult.StackTrace)));
                }
                xmlWriter.WriteEndElement();

                xmlWriter.WriteEndElement();
            }

            xmlWriter.WriteStartElement("results");
            foreach (TestResult result in suiteResult.Results)
            {
                result.Accept(this);
            }
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
        }