Пример #1
0
        /// <summary>
        ///  Write one test.
        /// </summary>
        /// <param name="tableWriter">Writer</param>
        /// <param name="areaReportsPath">Area path</param>
        /// <param name="area">Area name</param>
        /// <param name="test">TestRecord</param>
        /// <param name="testIndex">Index of the test</param>
        private static void WriteTestNode(XmlTableWriter tableWriter, string areaReportsPath, string area, TestRecord test, int testIndex)
        {
            TestInfo testInfo = test.TestInfo;

            string testLogsDirectory  = Path.Combine(areaReportsPath, ReportingUtilities.TestLogsDir);
            string testInfosDirectory = Path.Combine(areaReportsPath, ReportingUtilities.TestInfosDir);

            //Test Layer with attribute needed for all variation.
            tableWriter.WriteStartElement("Test");
            tableWriter.WriteAttributeString("Name", Escape(testInfo.Name));
            tableWriter.WriteAttributeString("KnownBugs", test.TestInfo.Bugs.ToCommaSeparatedList());
            tableWriter.WriteAttributeString("Priority", test.TestInfo.Priority.ToString());
            tableWriter.WriteAttributeString("Machine", ReportingUtilities.ReportMachine(test.Machine));

            string testInfoPath = Path.Combine(testInfosDirectory, String.Format("{0}_{1}.xml", area, testIndex));

            if (ReportingUtilities.InterpretTestOutcome(test) == Result.Fail)
            {
                ReportingUtilities.SaveTestInfo(testInfoPath, testInfo);
                tableWriter.WriteAttributeString("TestInfo", Path.Combine(ReportingUtilities.TestInfosDir, Path.GetFileName(testInfoPath)));
            }

            for (int variationIndex = 0; variationIndex < test.Variations.Count; variationIndex++)
            {
                VariationRecord variation = test.Variations[variationIndex];

                string variationLogPath = Path.Combine(testLogsDirectory, String.Format("{0}_{1}_{2}.log", area, testIndex, variationIndex));
                WriteVariationNode(tableWriter, variation, variationLogPath);
            }

            //SEMI HACK: Create a node to hold information for test, that are not needed for most variation.
            // This solves three problems:
            //           1 - Allows us to provide Test level information in tabular form
            //           2 - Allows us to include Test level execution logs in these reports
            // Note - To nest these things attribute in parent Test node, while less hacky, would create a different semantic from the perspective of any XML viewer, which would be bad. very bad.
            string testLogPath = Path.Combine(testLogsDirectory, String.Format("{0}_{1}.log", area, testIndex));

            WriteChildTestNode(tableWriter, test, testInfo, testLogPath);
            tableWriter.WriteEndElement();
        }