private static void Generate(TestRecords records, string path) { using (XmlTableWriter tableWriter = new XmlTableWriter(path)) { tableWriter.AddXsl(@"DrtReport.xsl"); tableWriter.WriteStartElement("Variations"); tableWriter.WriteAttributeString("PassRate", ReportingUtilities.CalculatePassRate(records)); foreach (TestRecord test in FilterNonPassingTests(records)) { TestInfo testInfo = test.TestInfo; { tableWriter.WriteStartElement("Variation"); tableWriter.WriteAttributeString("Area", testInfo.Area); tableWriter.WriteAttributeString("TestName", testInfo.Name); tableWriter.WriteAttributeString("Variation", "Test Level Summary"); tableWriter.WriteAttributeString("Duration", ReportingUtilities.FormatTimeSpanAsSeconds(ReportingUtilities.GetTestDuration(test))); //Total test execution Time tableWriter.WriteAttributeString("Result", ReportingUtilities.InterpretTestOutcome(test).ToString()); tableWriter.WriteAttributeString("Log", test.Log); tableWriter.WriteAttributeString("LogDir", ReportingUtilities.ReportPaths(test.LoggedFiles)); tableWriter.WriteEndElement(); } foreach (VariationRecord variation in test.Variations) { tableWriter.WriteStartElement("Variation"); tableWriter.WriteAttributeString("Area", testInfo.Area); tableWriter.WriteAttributeString("TestName", testInfo.Name); tableWriter.WriteAttributeString("Variation", variation.VariationName); tableWriter.WriteAttributeString("Duration", ReportingUtilities.FormatTimeSpanAsSeconds(ReportingUtilities.GetVariationDuration(variation))); tableWriter.WriteAttributeString("Result", variation.Result.ToString()); tableWriter.WriteAttributeString("Log", variation.Log); tableWriter.WriteAttributeString("LogDir", ReportingUtilities.ReportPaths(variation.LoggedFiles)); tableWriter.WriteEndElement(); } } tableWriter.WriteEndElement(); } }
private static void WriteVariationNode(XmlTableWriter tableWriter, VariationRecord variation, string variationLogPath) { bool logTruncated = false; tableWriter.WriteStartElement("Variation"); tableWriter.WriteAttributeString("Variation", variation.VariationName); tableWriter.WriteAttributeString("VariationId", variation.VariationId.ToString(CultureInfo.InvariantCulture)); tableWriter.WriteAttributeString("Duration", ReportingUtilities.FormatTimeSpanAsSeconds(ReportingUtilities.GetVariationDuration(variation))); tableWriter.WriteAttributeString("Result", variation.Result.ToString()); tableWriter.WriteAttributeString("Log", ReportingUtilities.ProcessLongLog(variation.Log, variationLogPath, ref logTruncated)); if (logTruncated) { tableWriter.WriteAttributeString("LogPath", Path.Combine(ReportingUtilities.TestLogsDir, Path.GetFileName(variationLogPath))); } tableWriter.WriteAttributeString("LogDir", ReportingUtilities.ReportPaths(variation.LoggedFiles)); tableWriter.WriteEndElement(); }