public MainInfoChart(MainStatistics stats, string id) { var data = "[" + $"{{name: 'Passed', y: {stats.TotalPassed}, color: '" + ReportColors.TestPassed + "'}," + $"{{name: 'Failed', y: {stats.TotalFailed}, color: '" + ReportColors.TestFailed + "'}," + $"{{name: 'Broken', y: {stats.TotalBroken}, color: '" + ReportColors.TestBroken + "'}," + $"{{name: 'Ignored', y: {stats.TotalIgnored}, color: '" + ReportColors.TestIgnored + "'}," + $"{{name: 'Inconclusive', y: {stats.TotalInconclusive}, color: '" + ReportColors.TestInconclusive + "'}" + "]"; JsCode = $@" $(function () {{ $('#{id}').highcharts({{ chart: {{ type: 'pie' }}, title: {{ text: 'Test results' }}, series: [{{ name: 'Results', data: {data} }}] }}); }});"; }
public MainInformationSection(MainStatistics stats) { var strWr = new StringWriter(); using (var writer = new HtmlTextWriter(strWr)) { writer .Class("columns") .Div(() => writer .Class("one-third column") .Div(() => writer .Div(() => writer .Class("border-bottom p-3 mb-3") .H2("Time: ") .Class("border border-0 p-3 mb-3") .Div(() => writer .Ul(() => writer .Li("Start datetime: " + stats.StartDate) .Li("Finish datetime: " + stats.EndDate) .Li("Duration: " + stats.Duration) ) ) ) .Div(() => writer .Class("border-bottom p-3 mb-3") .H2("Summary: ") .Class("border border-0 p-3 mb-3") .Div(() => writer .Ul(() => writer .Li("Total: " + stats.TotalAll) .Li("Success: " + stats.TotalPassed) .Li("Errors: " + stats.TotalBroken) .Li("Failures: " + stats.TotalFailed) .Li("Inconclusive: " + stats.TotalInconclusive) .Li("Ignored: " + stats.TotalIgnored) ) ) ) ) .Class("two-thirds column") .Div(() => writer .WithAttr(HtmlTextWriterAttribute.Id, Output.GetStatsPieId()) .Tag(HtmlTextWriterTag.Div) ) ); } HtmlCode = strWr.ToString(); }
public static void Main(string[] args) { var config = NunitGoHelper.Configuration; var outputPath = config.LocalOutputPath; var attachmentsPath = outputPath + @"\Attachments\"; PageGenerator.GenerateStyleFile(outputPath); var tests = NunitGoTestHelper.GetNewestTests(attachmentsPath).OrderBy(x => x.DateTimeFinish).ToList(); var stats = new MainStatistics(tests); var statsChart = new MainInfoChart(stats, Output.GetStatsPieId()); statsChart.SaveScript(outputPath); tests.GenerateTimelinePage(Path.Combine(outputPath, Output.Files.TimelineFile)); stats.GenerateMainStatisticsPage(Path.Combine(outputPath, Output.Files.TestStatisticsFile)); tests.GenerateTestListPage(Path.Combine(outputPath, Output.Files.TestListFile)); tests.GenerateReportMainPage(outputPath, stats); }
public void GenerateReport() { try { if (!_configuration.GenerateReport) { return; } const string cssPageName = Output.Files.ReportStyleFile; var cssFullPath = Path.Combine(_outputPath, cssPageName); if (!File.Exists(cssFullPath)) { PageGenerator.GenerateStyleFile(cssFullPath); } /* * var primerName = Output.Files.PrimerStyleFile; * ExtractResource(primerName, _outputPath); * * var octiconsName = Output.Files.OcticonsStyleFiles; * ExtractResources(octiconsName, _outputPath); * * //jquery - 1.11.0.min.js * var jqueryName = Output.Files.JQueryScriptFile; * ExtractResource(jqueryName, _outputPath); */ var tests = ReportTestHelper.GetNewestTests(_attachmentsPath).OrderBy(x => x.DateTimeFinish).ToList(); var stats = new MainStatistics(tests, _startSuite); var statsChart = new MainInfoChart(stats, Output.GetStatsPieId()); statsChart.SaveScript(_outputPath); tests.GenerateTimelinePage(Path.Combine(_outputPath, Output.Files.TimelineFile)); stats.GenerateMainStatisticsPage(Path.Combine(_outputPath, Output.Files.TestStatisticsFile)); tests.GenerateTestListPage(Path.Combine(_outputPath, Output.Files.TestListFile)); tests.GenerateReportMainPage(_outputPath, stats); } catch (Exception ex) { InternalLogs.Exception(ex, "Exception in GenerateReport"); } }
public static void GenerateMainStatisticsPage(this MainStatistics stats, string fullPath) { try { var reportMenuTitle = new SectionName("Main statistics"); var statisticsSection = new StatisticsSection(stats); var page = new HtmlPage("Main statistics page") { PageStylePaths = new List <string> { Output.Files.ReportStyleFile, Output.Files.PrimerStyleFile }, PageBodyCode = reportMenuTitle.HtmlCode + statisticsSection.HtmlCode }; page.SavePage(fullPath); } catch (Exception ex) { Log.Exception(ex, "Exception while generating main statistics page"); } }
public static void GenerateReportMainPage(this List <NunitGoTest> tests, string pathToSave, MainStatistics mainStats) { try { var menuElements = new List <ReportMenuItem> { new ReportMenuItem("Main statistics", Output.Files.TestStatisticsFile, "octicon octicon-graph"), new ReportMenuItem("Test list", Output.Files.TestListFile, "octicon octicon-checklist"), new ReportMenuItem("Timeline", Output.Files.TimelineFile, "octicon octicon-clock") }; var mainTitle = new SectionName("Test Run Report"); var mainInformation = new MainInformationSection(mainStats); var reportMenu = new MenuSection(menuElements, "main-menu", "Report menu"); var report = new HtmlPage("NUnitGo Report") { ScriptFilePaths = new List <string> { Output.Files.JQueryScriptFile, Output.Files.HighstockScriptFile, Output.Files.StatsScript }, PageStylePaths = new List <string> { Output.Files.ReportStyleFile, Output.Files.PrimerStyleFile, Output.Files.OcticonStyleFile }, PageBodyCode = mainTitle.HtmlCode + mainInformation.HtmlCode + reportMenu.ReportMenuHtml }; report.SavePage(Path.Combine(pathToSave, Output.Files.FullReportFile)); } catch (Exception ex) { Log.Exception(ex, "Exception while generating full report page"); } }
public StatisticsSection(MainStatistics mainStats, string height = "90%") { var testResultsList = new List <HorizontalBarElement> { new HorizontalBarElement("Passed", "Passed (" + mainStats.TotalPassed + @"/" + mainStats.TotalAll + ")", Colors.TestPassed, mainStats.TotalPassed / (double)mainStats.TotalAll), new HorizontalBarElement("Failed", "Failed (" + mainStats.TotalFailed + @"/" + mainStats.TotalAll + ")", Colors.TestFailed, mainStats.TotalFailed / (double)mainStats.TotalAll), new HorizontalBarElement("Broken", "Broken (" + mainStats.TotalBroken + @"/" + mainStats.TotalAll + ")", Colors.TestBroken, mainStats.TotalBroken / (double)mainStats.TotalAll), new HorizontalBarElement("Ignored", "Ignored (" + mainStats.TotalIgnored + @"/" + mainStats.TotalAll + ")", Colors.TestIgnored, mainStats.TotalIgnored / (double)mainStats.TotalAll), new HorizontalBarElement("Inconclusive", "Iconclusive (" + mainStats.TotalInconclusive + @"/" + mainStats.TotalAll + ")", Colors.TestInconclusive, mainStats.TotalInconclusive / (double)mainStats.TotalAll), new HorizontalBarElement("Unknown", "Unknown (" + mainStats.TotalUnknown + @"/" + mainStats.TotalAll + ")", Colors.TestUnknown, mainStats.TotalUnknown / (double)mainStats.TotalAll) }; var testResultsBar = new HorizontalBar("test-results-bar", "Test results bar", testResultsList); var testExecutedList = new List <HorizontalBarElement> { new HorizontalBarElement("Executed", "Executed (" + mainStats.TotalExecuted + @"/" + mainStats.TotalAll + ")", Colors.TestPassed, mainStats.TotalExecuted / (double)mainStats.TotalAll), new HorizontalBarElement("Not executed", "Not executed (" + (mainStats.TotalAll - mainStats.TotalExecuted).ToString("D") + @"/" + mainStats.TotalAll + ")", Colors.TestIgnored, (mainStats.TotalAll - mainStats.TotalExecuted) / (double)mainStats.TotalAll) }; var testExecutedBar = new HorizontalBar("test-success-bar", "Test success bar", testExecutedList); var testSuccessList = new List <HorizontalBarElement> { new HorizontalBarElement("True", "True (" + mainStats.TotalSuccessTrue + @"/" + mainStats.TotalExecuted + ")", Colors.TestPassed, mainStats.TotalSuccessTrue / (double)mainStats.TotalExecuted), new HorizontalBarElement("False", "False (" + mainStats.TotalSuccessFalse + @"/" + mainStats.TotalExecuted + ")", Colors.TestFailed, mainStats.TotalSuccessFalse / (double)mainStats.TotalExecuted) }; var testSuccessBar = new HorizontalBar("test-success-bar", "Test success bar", testSuccessList); var stringWriter = new StringWriter(); using (var writer = new HtmlTextWriter(stringWriter)) { writer.AddStyleAttribute(HtmlTextWriterStyle.Height, height); writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Colors.White); writer.AddStyleAttribute(HtmlTextWriterStyle.Overflow, "scroll"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddStyleAttribute(HtmlTextWriterStyle.Margin, "1% 2% 3% 97%"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.DangerButton("Back", Output.Files.FullReportFile); writer.RenderEndTag(); //DIV writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingLeft, "30px"); writer.RenderBeginTag(HtmlTextWriterTag.H3); writer.Write("Test cases results:"); writer.RenderEndTag(); writer.Write(testResultsBar.BarHtml); writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingLeft, "30px"); writer.RenderBeginTag(HtmlTextWriterTag.H3); writer.Write("Test cases success:"); writer.RenderEndTag(); writer.Write(testSuccessBar.BarHtml); writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingLeft, "30px"); writer.RenderBeginTag(HtmlTextWriterTag.H3); writer.Write("Executed test cases:"); writer.RenderEndTag(); writer.Write(testExecutedBar.BarHtml); writer.RenderEndTag(); //DIV } HtmlCode = stringWriter.ToString(); }