Example #1
0
        public override void Parse(XElement testSuite)
        {
            //TestSuite tt = InitFromXElement(testSuite);
            this.InitAttributeFromXElement(testSuite);

            string reason = testSuite.Element("reason")?.Element("message")?.Value;
            this.Reason = reason;

            var results = testSuite.Element("results");
            var subTS = results.Elements("test-suite");
            foreach (XElement _testSuite in subTS)
            {
                //TestSuite ttt = TestSuite.Parse(_testSuite);
                TestSuite ttt = new TestSuite();
                ttt.Parse(_testSuite);
                this.TestSuites.Add(ttt);
            }

            var testCases = results.Elements("test-case");
            foreach (XElement testCase in testCases)
            {
                TestCase test = new TestCase();
                test.Parse(testCase);
                this.TestCases.Add(test);
            }

            //return this;
        }
Example #2
0
        public static List<TestSuite> Parse(string path)
        {
            XDocument doc = XDocument.Load(path);

            env = Environment.InitFromXElement(doc.Root.Element("environment"));
            
            List<TestSuite> testFixtures = new List<TestSuite>();

            var globalTestSuites = doc.Root.Element("test-suite").Element("results").Elements("test-suite");
            foreach (XElement testSuite in globalTestSuites)
            {
                Console.WriteLine(testSuite.Attribute("name"));
                var _testSuites = testSuite.Element("results").Elements("test-suite");
                foreach (XElement ts in _testSuites)
                {
                    Console.WriteLine(ts.Attribute("name"));
                    var nTests = ts.Element("results").Elements("test-suite");

                    //TestSuite tt = TestSuite.Parse(ts);
                    TestSuite tt = new TestSuite();
                    tt.Parse(ts);

                    testFixtures.Add(tt);
                    Console.WriteLine(tt.Name);
                }
            }

            TestFixture = testFixtures.FirstOrDefault();
            return testFixtures;
        }
Example #3
0
        public static XElement GenerateHtml(TestSuite testFixture)
        {
            XElement html = new XElement("div");
            
            html.Add(env.GenerateHtml());
            html.Add(GetSuitesSummaryTable(testFixture));
            foreach (var testSuite in testFixture.TestSuites)
            {
                XElement testHeader = new XElement("h2", testSuite.Name);
                XElement table = GetTable(new[] { "Name", "Status", "Time" });

                XElement tbody = new XElement("tbody");
                XElement _html = testSuite.GenerateHtml();
                tbody.Add(_html);
                table.Add(tbody);

                html.Add(testHeader);
                html.Add(table);
            }

            return html;
        }
Example #4
0
        public static XElement GetSuitesSummaryTable(TestSuite testFixture)
        {
            XElement main = new XElement("div");
            XElement testHeader = new XElement("h2", "Test Suites");

            XElement table = GetTable(new[] { "Name", "Status", "Time" });
            XElement tbody = new XElement("tbody");
            foreach (var testSuite in testFixture.TestSuites)
            {
                XElement tr = new XElement("tr");
                XElement tdName = new XElement("td", testSuite.Name);
                XElement tdStatus = new XElement("td", testSuite.Result);
                XElement tdTime = new XElement("td", testSuite.Time);

                tr.Add(tdName);
                tr.Add(tdStatus);
                tr.Add(tdTime);

                tdName.SetAttributeValue("style", "text-align:left;");

                switch (testSuite.Result)
                {
                    case "Success":
                        tdStatus.SetAttributeValue("bgcolor", "green");
                        break;
                    case "Ignored":
                        tdStatus.SetAttributeValue("bgcolor", "yellow");
                        break;
                    case "Failure":
                        tdStatus.SetAttributeValue("bgcolor", "red");
                        break;
                }

                tbody.Add(tr);
            }

            table.Add(tbody);
            main.Add(testHeader);
            main.Add(table);

            return main;
        }