public void CreateSummaryData_ResultIsNull_Throws()
        {
            // Arrange
            var config = new AnalysisConfig()
            {
                SonarProjectKey = "Foo", SonarQubeHostUrl = "http://foo"
            };
            Action action = () => SummaryReportBuilder.CreateSummaryData(config, null);

            // Act & Assert
            action.Should().ThrowExactly <ArgumentNullException>().And.ParamName.Should().Be("result");
        }
示例#2
0
        public void SummaryReport_ReportIsGenerated()
        {
            // Arrange
            var hostUrl = "http://mySonarQube:9000";
            var result  = new ProjectInfoAnalysisResult();
            var config  = new AnalysisConfig()
            {
                SonarProjectKey = "Foo", SonarQubeHostUrl = hostUrl
            };

            var settings = TeamBuildSettings.CreateNonTeamBuildSettingsForTesting(TestContext.DeploymentDirectory);

            config.SonarOutputDir = TestContext.TestDeploymentDir; // this will be cleaned up by VS when there are too many results
            var expectedReportPath = Path.Combine(TestContext.TestDeploymentDir, SummaryReportBuilder.SummaryMdFilename);

            // Act
            var builder = new SummaryReportBuilder();

            builder.GenerateReports(settings, config, result, new TestLogger());

            // Assert
            Assert.IsTrue(File.Exists(expectedReportPath) && (new FileInfo(expectedReportPath)).Length > 0, "The report file cannot be found or is empty");
        }
示例#3
0
        public void SummaryReport_AllTypesOfProjects()
        {
            // Arrange
            var hostUrl = "http://mySonarQube:9000";
            var result  = new ProjectInfoAnalysisResult()
            {
                RanToCompletion = true
            };
            var config = new AnalysisConfig()
            {
                SonarProjectKey = "", SonarQubeHostUrl = hostUrl
            };

            AddProjectInfoToResult(result, ProjectInfoValidity.ExcludeFlagSet, type: ProjectType.Product, count: 4);
            AddProjectInfoToResult(result, ProjectInfoValidity.ExcludeFlagSet, type: ProjectType.Test, count: 1);
            AddProjectInfoToResult(result, ProjectInfoValidity.InvalidGuid, type: ProjectType.Product, count: 7);
            AddProjectInfoToResult(result, ProjectInfoValidity.InvalidGuid, type: ProjectType.Test, count: 8);
            AddProjectInfoToResult(result, ProjectInfoValidity.NoFilesToAnalyze, count: 11);
            AddProjectInfoToResult(result, ProjectInfoValidity.Valid, type: ProjectType.Product, count: 13);
            AddProjectInfoToResult(result, ProjectInfoValidity.Valid, type: ProjectType.Test, count: 17);
            AddProjectInfoToResult(result, ProjectInfoValidity.DuplicateGuid, type: ProjectType.Product, count: 5);
            AddProjectInfoToResult(result, ProjectInfoValidity.DuplicateGuid, type: ProjectType.Test, count: 3);

            // Act
            var summaryReportData = SummaryReportBuilder.CreateSummaryData(config, result);

            // Assert
            VerifySummaryReportData(summaryReportData, result, hostUrl, config);
            VerifySummaryProjectCounts(
                summaryReportData,
                expectedExcludedProjects: 5, // ExcludeFlagSet
                expectedInvalidProjects: 23, // InvalidGuid, DuplicateGuid
                expectedSkippedProjects: 11, // No files to analyze
                expectedProductProjects: 13,
                expectedTestProjects: 17);
        }
示例#4
0
        private static void ExecuteReportBuilder(ILogger logger, AnalysisConfig config, ILegacyTeamBuildFactory teamBuildFactory, ITeamBuildSettings teamBuildSettings, bool ranToCompletion, string fullPropertiesFilePath)
        {
            var reportBuilder = new SummaryReportBuilder(teamBuildFactory, logger);

            reportBuilder.GenerateReports(teamBuildSettings, config, ranToCompletion, fullPropertiesFilePath);
        }