Ejemplo n.º 1
0
        /// <summary>
        /// Write a Test node under Test, to hold information for the Test: log, test result, duration, Test info, which
        /// won't show for every Variation in Xml viewer.
        /// </summary>
        /// <param name="tableWriter">Writer</param>
        /// <param name="test">test</param>
        /// <param name="testInfo">testInfo</param>
        /// <param name="testLogPath">test log path</param>
        private static void WriteChildTestNode(XmlTableWriter tableWriter, TestRecord test, TestInfo testInfo, string testLogPath)
        {
            bool logTruncated = false;

            tableWriter.WriteStartElement("Test");
            tableWriter.WriteAttributeString("Duration", ReportingUtilities.FormatTimeSpanAsSeconds(ReportingUtilities.GetTestDuration(test))); //Total test execution Time
            tableWriter.WriteAttributeString("Result", ReportingUtilities.InterpretTestOutcome(test).ToString());
            tableWriter.WriteAttributeString("Log", ReportingUtilities.ProcessLongLog(test.Log, testLogPath, ref logTruncated));
            if (logTruncated)
            {
                tableWriter.WriteAttributeString("LogPath", Path.Combine(ReportingUtilities.TestLogsDir, Path.GetFileName(testLogPath)));
            }
            tableWriter.WriteAttributeString("LogDir", ReportingUtilities.ReportPaths(test.LoggedFiles));

            int  failed      = 0;
            int  failedOnBug = 0;
            bool hasBugs     = ReportingUtilities.TestHasBugs(testInfo);

            foreach (VariationRecord variation in test.Variations)
            {
                failed      += ReportingUtilities.OneForFail(variation.Result);
                failedOnBug += ReportingUtilities.OneForFailOnBug(variation.Result, hasBugs);
            }
            tableWriter.WriteAttributeString("Failures", string.Format("{0}", failed - failedOnBug));
            tableWriter.WriteAttributeString("Total", string.Format("{0}", test.Variations.Count));
            tableWriter.WriteEndElement();
        }
Ejemplo n.º 2
0
        internal static SortedDictionary <string, AreaSummaryEntry> ProduceAreaSummaries(TestRecords tests)
        {
            SortedDictionary <string, AreaSummaryEntry> SummaryTable = new SortedDictionary <string, AreaSummaryEntry>(StringComparer.OrdinalIgnoreCase);

            //Go through VariationRecords in each test to build up SummaryStats
            foreach (TestRecord test in tests.TestCollection)
            {
                AreaSummaryEntry entry;
                string           area = test.TestInfo.Area;

                //Create Entry if area doesn't exist yet, else load it up
                if (!SummaryTable.ContainsKey(area))
                {
                    entry = new AreaSummaryEntry();
                    entry.TestExecutionTime = new TimeSpan();
                    entry.Name            = area;
                    entry.AssociatedTests = new TestCollection();
                    SummaryTable.Add(area, entry);
                }
                else
                {
                    entry = SummaryTable[area];
                }
                entry.AssociatedTests.Add(test);
                bool hasBugs = (test.TestInfo.Bugs != null && test.TestInfo.Bugs.Count > 0);
                foreach (VariationRecord variation in test.Variations)
                {
                    entry.TotalVariations          += ReportingUtilities.OneForCountable(variation.Result);
                    entry.FailedVariations         += ReportingUtilities.OneForFail(variation.Result);
                    entry.IgnoredVariations        += ReportingUtilities.OneForIgnore(variation.Result);
                    entry.FailedVariationsWithBugs += ReportingUtilities.OneForFailOnBug(variation.Result, hasBugs);
                }
                entry.TestExecutionTime += test.Duration;
            }

            foreach (ExecutionGroupRecord group in tests.ExecutionGroupRecords)
            {
                AreaSummaryEntry entry;
                string           area = group.Area;
                //Assumption - all areas have been defined by the list of tests scanned in above loop
                entry = SummaryTable[area];

                entry.TotalExecutionTime += ReportingUtilities.GetGroupDuration(group);
                // Take the earliest start time as the start of the entire area
                if (entry.StartTime < group.StartTime.DateTime)
                {
                    entry.StartTime = group.StartTime.DateTime;
                }

                // Take the last end time as the end of the entire area
                if (group.EndTime.DateTime > entry.EndTime)
                {
                    entry.EndTime = group.EndTime.DateTime;
                }
            }

            return(SummaryTable);
        }
Ejemplo n.º 3
0
        private static Dictionary <string, MachineSummaryEntry> ProduceMachineSummaries(TestRecords tests)
        {
            Dictionary <string, MachineSummaryEntry> SummaryTable = new Dictionary <string, MachineSummaryEntry>(StringComparer.OrdinalIgnoreCase);

            //Go through VariationRecords in each test to build up SummaryStats
            foreach (TestRecord test in tests.TestCollection)
            {
                MachineSummaryEntry entry;
                string name = ReportingUtilities.ReportMachine(test.Machine);

                //Create Entry if machine doesn't exist yet, else load it up
                if (!SummaryTable.ContainsKey(name))
                {
                    entry = new MachineSummaryEntry();
                    entry.TestExecutionTime = TimeSpan.Zero;
                    entry.Name = name;
                    SummaryTable.Add(name, entry);
                }
                else
                {
                    entry = SummaryTable[name];
                }
                bool hasBugs = (test.TestInfo.Bugs != null && test.TestInfo.Bugs.Count > 0);
                foreach (VariationRecord variation in test.Variations)
                {
                    entry.TotalVariations          += ReportingUtilities.OneForCountable(variation.Result);
                    entry.FailedVariations         += ReportingUtilities.OneForFail(variation.Result);
                    entry.FailedVariationsWithBugs += ReportingUtilities.OneForFailOnBug(variation.Result, hasBugs);
                }
                entry.TestExecutionTime += ReportingUtilities.GetTestDuration(test);

                if (test.Variations.Count == 0)
                {
                    entry.TestsWithoutVariation += 1;
                }
            }
            return(SummaryTable);
        }