コード例 #1
0
        private void GenerateReport()
        {
            try
            {
                if (!_configuration.GenerateReport) return;

                if (_nunitGoTest.HasOutput)
                {
                    var testOutputPath = _nunitGoTest.AttachmentsPath + Output.Files.TestOutputFile;
                    PageGenerator.GenerateTestOutputPage(testOutputPath, TestContext.Out.ToString(), "./../../" + _nunitGoTest.TestHrefRelative);
                    _nunitGoTest.HasOutput = true;
                }
                var testPath = _nunitGoTest.AttachmentsPath + Output.Files.TestHtmlFile;
                _nunitGoTest.GenerateTestPage(testPath);

                var outputPath = _configuration.LocalOutputPath;
                PageGenerator.GenerateStyleFile(outputPath);

                var tests = NunitGoTestHelper.GetTests(_configuration.LocalOutputPath).OrderBy(x => x.DateTimeFinish).ToList();
                var stats = new MainStatistics(tests);
                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)
            {
                Log.Exception(ex, "Exception in GenerateReport");
            }
        }
コード例 #2
0
ファイル: PageGenerator.cs プロジェクト: TomDrJones/NUnitGo
	    public static void GenerateReportMainPage(this List<NunitGoTest> tests, 
            string pathToSave, MainStatistics mainStats)
        {
            try
            {
                var report = new HtmlPage();

                var mainTitle = new PageTitle();
                report.AddToBody(mainTitle.HtmlCode);

                var mainInformation = new MainInformationSection(mainStats);
                report.AddToBody(mainInformation.HtmlCode);

                var reportMenuTitle = new PageTitle("Report menu", "report-main-menu");
                report.AddToBody(reportMenuTitle.HtmlCode);

                var menuElements = new List<ReportMenuItem>
			    {
				    new ReportMenuItem("Main statistics", Output.Files.TestStatisticsFile),
				    new ReportMenuItem("Test list", Output.Files.TestListFile),
				    new ReportMenuItem("Timeline", Output.Files.TimelineFile)
			    };
                var reportMenu = new MenuSection(menuElements, "main-menu", "Main Menu");
                report.AddToBody(reportMenu.ReportMenuHtml);

                var footer = new FooterSection();
                report.AddInsideTag("footer", footer.HtmlCode);

                var reportPageName = Output.Files.FullReportFile;
                report.SavePage(Path.Combine(pathToSave, reportPageName));
            }
            catch (Exception ex)
            {
                Log.Exception(ex, "Exception while generating full report page");
            }
		}
コード例 #3
0
        public MainInformationSection(MainStatistics stats)
        {
            Style = GetStyle();

            var strWr = new StringWriter();
            using (var writer = new HtmlTextWriter(strWr))
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "table");
                writer.AddAttribute(HtmlTextWriterAttribute.Id, Id);
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "table-cell");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "column-1");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.RenderBeginTag(HtmlTextWriterTag.H1);
                writer.Write("Main information:");
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Start Date: " + stats.StartDate);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Finish Date: " + stats.EndDate);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Time: " + stats.Duration);
                writer.RenderEndTag();
                writer.RenderEndTag();//DIV
                
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "table-cell");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "column-2");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.RenderBeginTag(HtmlTextWriterTag.H1);
                writer.Write("Main results:");
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Total: " + stats.TotalAll);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Success: " + stats.TotalPassed);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Errors: " + stats.TotalBroken);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Failures: " + stats.TotalFailed);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Inconclusive: " + stats.TotalInconclusive);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Ignored: " + stats.TotalIgnored);
                writer.RenderEndTag();
                writer.RenderEndTag();

                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "table-cell");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "column-3");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.RenderBeginTag(HtmlTextWriterTag.H1);
                writer.Write("Environment:");
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "CLR version: " + System.Environment.Version);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "OS version: " + System.Environment.OSVersion.VersionString);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Platform: " + System.Environment.OSVersion.Platform);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "Machine name: " + System.Environment.MachineName);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "User domain: " + System.Environment.UserName);
                writer.RenderEndTag();
                writer.RenderBeginTag(HtmlTextWriterTag.P);
                writer.Write(Bullet.HtmlCode + "User: " + System.Environment.UserDomainName);
                writer.RenderEndTag();
                writer.RenderEndTag();//DIV
                
                writer.RenderEndTag();//DIV
            }

            HtmlCode = strWr.ToString();
        }
コード例 #4
0
        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.Write(new CloseButton("Back", Output.Files.FullReportFile).ButtonHtml);
                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();
        }