示例#1
0
        private IEnumerable<QUnitTest> GrabTestResultsFromWebPage(HtmlPage testPage)
        {
            var documentRoot = testPage.getElementById("qunit-tests");

            XmlDocument xmlResults = new XmlDocument();
            xmlResults.LoadXml(documentRoot.asXml());

            var results = new List<QUnitTest>();

            foreach (XmlNode result in xmlResults.FirstChild.ChildNodes)
            {

                var resultClass = result.Attributes["class"].Value;

                var testName = result.SelectSingleNode("strong/span[@class='test-name']/text()").Value.Trim();

                var message = "";
                var failMessageItem = result.SelectSingleNode("ol/li[@class='fail']/text()");
                if (failMessageItem != null)
                {

                    message = failMessageItem.Value.Trim();
                }

                yield return new QUnitTest
                {
                    FileName = "",
                    TestName = testName.ToString(),
                    Result = resultClass,
                    Message = message
                };

            }
        }