public static TestResults InterpretTestResults(XmlDocument doc)
        {
            TestResults results = new TestResults();
            XmlNamespaceManager nsm = new XmlNamespaceManager(doc.NameTable);
            nsm.AddNamespace("n", "http://microsoft.com/schemas/VisualStudio/TeamTest/2010");

            results.Outcome = doc.SelectSingleNode("n:TestRun/n:ResultSummary", nsm).Attributes["outcome"].Value;
            results.CountExecuted = int.Parse(doc.SelectSingleNode("n:TestRun/n:ResultSummary/n:Counters", nsm).Attributes["executed"].Value);
            results.CountPassed = int.Parse(doc.SelectSingleNode("n:TestRun/n:ResultSummary/n:Counters", nsm).Attributes["passed"].Value);
            results.CountFailed = int.Parse(doc.SelectSingleNode("n:TestRun/n:ResultSummary/n:Counters", nsm).Attributes["failed"].Value);

            XmlNodeList testresults = doc.SelectNodes("n:TestRun/n:Results/n:UnitTestResult[@outcome='Failed']", nsm);
            string names = string.Empty;
            foreach (XmlNode testresult in testresults)
            {
                string message = testresult.Attributes["testName"].Value;
                XmlNode xmlErrorInfoNode = testresult.SelectSingleNode("n:Output/n:ErrorInfo/n:Message", nsm);
                if (xmlErrorInfoNode != null)
                {
                    message += ": " + xmlErrorInfoNode.InnerText;
                    results.ResultCode = ExitCode.Failure;
                }

                results.FailingTests.Add(message);
            }

            return results;
        }
Ejemplo n.º 2
0
      public void DefaultValues()
      {
          TestResults t = new TestResults();
 
          Assert.AreEqual(0, t.CountExecuted);
          Assert.AreEqual(0, t.CountFailed);
          Assert.AreEqual(0, t.CountPassed);
          Assert.AreEqual(string.Empty, t.Outcome);
          Assert.IsNotNull(t.FailingTests);
          Assert.IsNull(t.CoveredAssemblies);
      }
        public static TestResults InterpretTestResults(string path)
        {
            TestResults results = new TestResults();
            if (File.Exists(path))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(path);

                results = InterpretTestResults(doc);
            }
            return results;
        }
Ejemplo n.º 4
0
        public void SettersAndGetters()
        {
            TestResults t = new TestResults();
            t.CountExecuted = 2;
            t.CountFailed = 5;
            t.CountPassed = 4;
            t.Outcome = "Completed";

            Assert.AreEqual(2, t.CountExecuted);
            Assert.AreEqual(5, t.CountFailed);
            Assert.AreEqual(4, t.CountPassed);
            Assert.AreEqual("Completed", t.Outcome);
        }