Esempio n. 1
0
        /// <summary>
        /// Opens a JUNIT report and adds its results to the Ranorex Report
        /// </summary>
        /// <param name="workdir">The directory where the report file is located</param>
        /// <param name="fileName">Name of the report file</param>
        public void ParseExtTestResults(string workdir, string fileName)
        {
            XmlDocument xdoc = new XmlDocument();

            try
            {
                xdoc.Load(workdir + fileName);

                XmlNode     xtestsuite = xdoc.SelectSingleNode("/testsuite");
                XmlNodeList testcases  = xdoc.SelectNodes("/testsuite/testcase");

                string sHead = string.Format("External Selenium Test completed. {0} out of {1} test cases successful",
                                             Int32.Parse(xtestsuite.Attributes["tests"].Value) - Int32.Parse(xtestsuite.Attributes["failures"].Value),
                                             Int32.Parse(xtestsuite.Attributes["tests"].Value));

                TestReport.BeginTestEntryContainer(1, "Selenium Test Suite (external)", ActivityExecType.Execute, TestEntryActivityType.TestCase);
                TestReport.BeginSmartFolderContainer("Selenium", sHead);

                Report.Info("Selenium", "Parsing Results...");


                foreach (XmlNode n in testcases)
                {
                    Ranorex.Core.Reporting.TestReport.BeginTestCaseContainer(n.Attributes["classname"].Value + "." + n.Attributes["name"].Value);
                    Ranorex.Core.Reporting.TestReport.BeginTestModule("Module " + n.Attributes["name"].Value);

                    if (n.SelectSingleNode("failure") != null)
                    {
                        Report.Failure("Selenium", "Test case " + n.Attributes["name"].Value + " (" + n.Attributes["classname"].Value + ") \n" +
                                       n.SelectSingleNode("failure").Attributes["message"].Value);

                        Ranorex.Core.Reporting.TestReport.EndTestModule();
                        Ranorex.Core.Reporting.TestReport.EndTestCaseContainer(TestResult.Failed);
                        continue;
                    }


                    Report.Success("Selenium", "Test case " + n.Attributes["name"].Value + " (" + n.Attributes["classname"].Value + ")");

                    Ranorex.Core.Reporting.TestReport.EndTestModule();
                    Ranorex.Core.Reporting.TestReport.EndTestCaseContainer(TestResult.Passed);
                }

                TestReport.EndTestCaseContainer();
                TestReport.EndTestEntryContainer();
            }
            catch (Exception e)
            {
                Report.Error("Selenium", "Error reading Results\n" + e.Message);
            }
        }