Ejemplo n.º 1
0
        public XElement Generate(TestCase testCase)
        {
            XElement main = new XElement("div");

            XElement tr = new XElement("tr");
            XElement tdName = new XElement("td", testCase.Desription);
            XElement tdStatus = new XElement("td", testCase.Result);
            XElement tdTime = new XElement("td", testCase.Time);

            XElement trMessage = new XElement("tr");
            XElement tdMessage = new XElement("td");


            if (testCase.Message != null || testCase.StackTrace != null)
            {
                XElement preMessage = new XElement("pre", testCase.Message);
                XElement preStackTrace = new XElement("pre", testCase.StackTrace);
                tdMessage.SetValue("MESSAGE:\n");

                tdMessage.Add(preMessage);
                tdMessage.Add(preStackTrace);
                trMessage.Add(tdMessage);
            }
            else if (!string.IsNullOrEmpty(testCase.Reason))
            {
                XElement reasonMessage = new XElement("pre", testCase.Reason);
                tdMessage.Add(reasonMessage);
                trMessage.Add(tdMessage);
            }

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

            main.Add(tr);
            main.Add(trMessage);

            tdName.SetAttributeValue("style", "text-align:left;");
            trMessage.SetAttributeValue("style", "font-size:11px; text-align:left;");
            trMessage.SetAttributeValue("bgcolor", "lightgrey");
            tdMessage.SetAttributeValue("colspan", "3");


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

            return main;
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        public TestCase Parse(TestCase source, XElement testCase)
        {
            //TestCase tt = new TestCase();//= InitFromXElement(testCase);
            TestCase tt = source;
            tt.InitAttributeFromXElement(testCase);

            string message = testCase.Element("failure")?.Element("message")?.Value;
            tt.Message = message;
            string stackTrace = testCase.Element("failure")?.Element("stack-trace")?.Value;
            tt.StackTrace = stackTrace;

            string reason = testCase.Element("reason")?.Element("message")?.Value;
            tt.Reason = reason;

            return tt;
        }