/// <summary> /// Adds the XML representation of the result as a child of the /// supplied parent node.. /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="recursive">If true, descendant results are included</param> /// <returns></returns> public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive) { // A result node looks like a test node with extra info added XmlNode thisNode = Test.AddToXml(parentNode, false); thisNode.AddAttribute("result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString()) { thisNode.AddAttribute("label", ResultState.Label); } thisNode.AddAttribute("time", Duration.ToString()); if (Test is TestSuite) { thisNode.AddAttribute("total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString()); thisNode.AddAttribute("passed", PassCount.ToString()); thisNode.AddAttribute("failed", FailCount.ToString()); thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString()); thisNode.AddAttribute("skipped", SkipCount.ToString()); } thisNode.AddAttribute("asserts", AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(thisNode); break; case TestStatus.Skipped: AddReasonElement(thisNode); break; case TestStatus.Passed: case TestStatus.Inconclusive: if (Message != null) { AddReasonElement(thisNode); } break; } if (recursive && HasChildren) { foreach (TestResult child in Children) { child.AddToXml(thisNode, recursive); } } return(thisNode); }
public virtual XmlNode AddToXml(XmlNode parentNode, bool recursive) { XmlNode xmlNode = test.AddToXml(parentNode, recursive: false); XmlHelper.AddAttribute(xmlNode, "result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) { XmlHelper.AddAttribute(xmlNode, "label", ResultState.Label); } XmlHelper.AddAttribute(xmlNode, "time", Time.ToString("0.000", CultureInfo.InvariantCulture)); if (test is TestSuite) { XmlHelper.AddAttribute(xmlNode, "total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString()); XmlHelper.AddAttribute(xmlNode, "passed", PassCount.ToString()); XmlHelper.AddAttribute(xmlNode, "failed", FailCount.ToString()); XmlHelper.AddAttribute(xmlNode, "inconclusive", InconclusiveCount.ToString()); XmlHelper.AddAttribute(xmlNode, "skipped", SkipCount.ToString()); } XmlHelper.AddAttribute(xmlNode, "asserts", AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(xmlNode); break; case TestStatus.Skipped: AddReasonElement(xmlNode); break; } if (recursive && HasChildren) { foreach (TestResult child in Children) { child.AddToXml(xmlNode, recursive); } } return(xmlNode); }
/// <summary> /// Adds the XML representation of the result as a child of the /// supplied parent node.. /// </summary> /// <param name="parentNode">The parent node.</param> /// <param name="recursive">If true, descendant results are included</param> /// <returns></returns> public virtual TNode AddToXml(TNode parentNode, bool recursive) { // A result node looks like a test node with extra info added TNode thisNode = Test.AddToXml(parentNode, false); thisNode.AddAttribute("result", ResultState.Status.ToString()); if (ResultState.Label != string.Empty) // && ResultState.Label != ResultState.Status.ToString()) { thisNode.AddAttribute("label", ResultState.Label); } if (ResultState.Site != FailureSite.Test) { thisNode.AddAttribute("site", ResultState.Site.ToString()); } thisNode.AddAttribute("start-time", StartTime.ToString("u")); thisNode.AddAttribute("end-time", EndTime.ToString("u")); thisNode.AddAttribute("duration", Duration.ToString("0.000000", NumberFormatInfo.InvariantInfo)); if (Test is TestSuite) { thisNode.AddAttribute("total", (PassCount + FailCount + SkipCount + InconclusiveCount).ToString()); thisNode.AddAttribute("passed", PassCount.ToString()); thisNode.AddAttribute("failed", FailCount.ToString()); thisNode.AddAttribute("inconclusive", InconclusiveCount.ToString()); thisNode.AddAttribute("skipped", SkipCount.ToString()); } thisNode.AddAttribute("asserts", AssertCount.ToString()); switch (ResultState.Status) { case TestStatus.Failed: AddFailureElement(thisNode); break; case TestStatus.Skipped: case TestStatus.Passed: case TestStatus.Inconclusive: if (Message != null) { AddReasonElement(thisNode); } break; } if (Output.Length > 0) { AddOutputElement(thisNode); } if (recursive && HasChildren) { foreach (TestResult child in Children) { child.AddToXml(thisNode, recursive); } } return(thisNode); }