Ejemplo n.º 1
0
        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);
        }