private void WriteFailureElement(IUnitTestScenarioResult result)
        {
            xmlWriter.WriteStartElement("failure");

            xmlWriter.WriteStartElement("message");

            string errorMsg = "Unknown";
            string stackTrace = "Unknown";
            if (result.Exception != null)
            {
                if (result.Exception.Message != null)
                {
                    errorMsg = result.Exception.Message;
                }

                if (result.Exception.StackTrace != null)
                {
                    stackTrace = result.Exception.StackTrace;
                }
            }

            WriteCData(errorMsg);

            xmlWriter.WriteEndElement();

            xmlWriter.WriteStartElement("stack-trace");

            WriteCData(StackTraceFilter.Filter(stackTrace));
            xmlWriter.WriteEndElement();

            xmlWriter.WriteEndElement();
        }
        private void WriteResultElement(IUnitTestScenarioResult result)
        {
            xmlWriter.WriteStartElement("test-case");
            xmlWriter.WriteAttributeString("name", result.TestMethod.Name);

            xmlWriter.WriteAttributeString("executed", (result.Result != UnitTestOutcome.NotExecuted).ToString());
            xmlWriter.WriteAttributeString("result", result.Result == UnitTestOutcome.Passed ? "Success" : "Error");

            /*
            if (result.Result == UnitTestOutcome.Passed)
            {
            */
                xmlWriter.WriteAttributeString("success", (result.Result == UnitTestOutcome.Passed).ToString());
                xmlWriter.WriteAttributeString("time", (result.Finished-result.Started).TotalSeconds.ToString("#####0.000", NumberFormatInfo.InvariantInfo));
                xmlWriter.WriteAttributeString("asserts", "0");
            /*
            }
            */

            switch (result.Result)
            {
                case UnitTestOutcome.Failed:
                case UnitTestOutcome.Error:
                case UnitTestOutcome.Timeout:
                    WriteFailureElement(result);
                    break;
            }

            xmlWriter.WriteEndElement(); // test element
        }
Ejemplo n.º 3
0
 public TestMethodFinishedEventArgs(IUnitTestScenarioResult result)
 {
     Result = result;
 }