Пример #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();
        }
Пример #2
0
        /// <summary>
        /// Produces a simple console summary report
        /// </summary>
        internal static void WriteSummaryToConsole(TestRecords results)
        {
            Console.WriteLine();
            Console.WriteLine("A total of {0} test Infos were processed, with the following results.", results.TestCollection.Count);
            if (results.TestCollection.Count > 0)
            {
                int Pass          = 0;
                int Fail          = 0;
                int FailWithBugID = 0;
                int Ignore        = 0;

                #if REPORT_VERSIONS
                Dictionary <String, Tuple <int, List <TestInfo> > > dict = new Dictionary <String, Tuple <int, List <TestInfo> > >();
                #endif

                foreach (TestRecord test in results.TestCollection)
                {
                    TestInfo testInfo = test.TestInfo;

                    switch (ReportingUtilities.InterpretTestOutcome(test))
                    {
                    case Result.Ignore:
                        Ignore++;
                        break;

                    case Result.Pass:
                        Pass++;
                        break;

                    case Result.Fail:
                        Fail++;
                        if (ReportingUtilities.TestHasBugs(testInfo))
                        {
                            FailWithBugID++;
                        }
                        break;
                    }

                    #if REPORT_VERSIONS
                    String key = (testInfo.Versions == null)
                        ? String.Empty
                        : String.Join(",", ToArray(testInfo.Versions));

                    if (!dict.ContainsKey(key))
                    {
                        dict.Add(key, new Tuple <int, List <TestInfo> >(0, new List <TestInfo>()));
                    }

                    Tuple <int, List <TestInfo> > tuple = dict[key];
                    List <TestInfo> list = tuple.Item2;
                    if (list.Count < 5)
                    {
                        list.Add(testInfo);
                    }
                    dict[key] = new Tuple <int, List <TestInfo> >(tuple.Item1 + 1, list);
                    #endif
                }

                Console.WriteLine(" Passed: {0}", Pass);
                Console.WriteLine(" Failed (need to analyze): {0}", Fail - FailWithBugID);
                Console.WriteLine(" Failed (with BugIDs): {0}", FailWithBugID);
                Console.WriteLine(" Ignore: {0}", Ignore);
                Console.WriteLine();

                #if REPORT_VERSIONS
                foreach (KeyValuePair <string, Tuple <int, List <TestInfo> > > kvp in dict)
                {
                    Tuple <int, List <TestInfo> > tuple = kvp.Value;
                    Console.WriteLine("{0} tests with versions '{1}'", tuple.Item1, kvp.Key);
                    foreach (TestInfo testInfo in tuple.Item2)
                    {
                        Console.WriteLine("   /Area={0} /SubArea={1} /Name={2}",
                                          testInfo.Area, testInfo.SubArea, testInfo.Name);
                    }
                }
                #endif
            }
        }