Esempio n. 1
0
        private Report CreateReport(string path)
        {
            var report = new Report(path, true);

            foreach (var category in _categories)
            {
                report.AddCategory(category);
                report.AddDisciplines(category.Disciplines);
            }
            return(report);
        }
Esempio n. 2
0
 public void AddCategory_Doesnt_Throw_Exception()
 {
     try
     {
         var cat = new Category("ОД")
         {
             Title         = "Общеобразовательная подготовка",
             MaxLoad       = 2106,
             SelfGuided    = 702,
             StatutoryLoad = new StatutoryLoad
             {
                 Total = 1404,
                 LIZWithoutDivision = 184,
                 LIZWithDivision    = 299
             }
         };
         _report.AddCategory(cat);
     }
     catch (Exception e)
     {
         Assert.Fail(e.Message);
     }
 }
Esempio n. 3
0
        public Report Parse(string resultsFile)
        {
            var doc = XDocument.Load(resultsFile);

            var report = new Report();

            report.FileName     = Path.GetFileNameWithoutExtension(resultsFile);
            report.AssemblyName = doc.Descendants(xns + "files").First().Descendants(xns + "file").First().Value;
            report.TestParser   = this;

            // run-info & environment values -> RunInfo
            var runInfo = CreateRunInfo(doc, report).Info;

            report.AddRunInfo(runInfo);

            // test cases
            var tests = doc.Descendants(xns + "testStep")
                        .Where(x => x.Attribute("isTestCase").Value.Equals("true", StringComparison.CurrentCultureIgnoreCase));

            // report counts
            var statistics = doc.Descendants(xns + "statistics").First();

            report.Total        = tests.Count();
            report.Passed       = Int32.Parse(statistics.Attribute("passedCount").Value);
            report.Failed       = Int32.Parse(statistics.Attribute("failedCount").Value);
            report.Inconclusive = Int32.Parse(statistics.Attribute("inconclusiveCount").Value);
            report.Skipped      = Int32.Parse(statistics.Attribute("skippedCount").Value);
            report.Errors       = 0;

            // report duration
            XElement testPackageRun = doc.Descendants(xns + "testPackageRun").First();

            report.StartTime = testPackageRun.Attribute("startTime").Value;
            report.EndTime   = testPackageRun.Attribute("endTime").Value;

            var       suitesList = new List <string>();
            TestSuite testSuite  = null;

            tests.AsParallel().ToList().ForEach(tc =>
            {
                var testSuiteName = tc.Attribute("fullName").Value;
                testSuiteName     = testSuiteName.Contains('/')
                    ? testSuiteName.Split('/')[testSuiteName.Split('/').Length - 2]
                    : testSuiteName;

                if (!suitesList.Contains(testSuiteName))
                {
                    testSuite           = new TestSuite();
                    testSuite.Name      = testSuiteName;
                    testSuite.StartTime = tc.Parent.Attribute("startTime").Value;
                    testSuite.EndTime   = tc.Parent.Attribute("endTime").Value;

                    report.TestSuiteList.Add(testSuite);

                    suitesList.Add(testSuiteName);
                }

                var test = new Model.Test();

                test.Name   = tc.Attribute("name").Value;
                test.Status = StatusExtensions.ToStatus(tc.Parent.Descendants(xns + "outcome").First().Attribute("status").Value);

                // main a master list of all status
                // used to build the status filter in the view
                report.AddStatus(test.Status);

                var entry = tc.Descendants(xns + "entry");

                // description
                var description = entry != null
                    ? entry.Where(x => x.Attribute("key").Value.Equals("Description"))
                    : null;
                test.Description = description != null && description.Count() > 0
                    ? description.First().Value
                    : "";

                // error and other status messages
                var ignoreReason = entry != null
                    ? entry.Where(x => x.Attribute("key").Value.Equals("IgnoreReason"))
                    : null;
                test.StatusMessage = ignoreReason != null && ignoreReason.Count() > 0
                    ? ignoreReason.First().Value
                    : "";

                var testLog         = tc.Parent.Descendants(xns + "testLog");
                test.StatusMessage += testLog != null && testLog.Count() > 0
                    ? testLog.First().Value
                    : "";

                // assign categories
                var category = entry != null
                    ? entry.Where(x => x.Attribute("key").Value.Equals("Category"))
                    : null;
                if (category != null && category.Count() > 0)
                {
                    category.ToList().ForEach(s =>
                    {
                        string cat = s.Value;

                        test.CategoryList.Add(cat);
                        report.AddCategory(cat);
                    });
                }

                testSuite.TestList.Add(test);
                testSuite.Status = ReportUtil.GetFixtureStatus(testSuite.TestList);
            });

            return(report);
        }