public void Maven_Jacoco_EnableCodeCoverageForLog4JAppender()
 {
     SetupMocks();
     LoadBuildFile(CodeCoverageTestConstants.LogAppenderPomXml);
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", _classFilter);
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportdirectory", _reportDirectory);
     enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs));
     VerifyJacocoCoverageForMaven(checkForPluginManagement: false);
     Assert.Equal(_warnings.Count, 0);
     Assert.Equal(_errors.Count, 0);
 }
 public void Maven_EnableCodeCoverageForJacocoWhenCodeCoverageIsAlreadyEnabled()
 {
     SetupMocks();
     LoadBuildFile(CodeCoverageTestConstants.PomWithJacocoCCXml);
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", _classFilter);
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportdirectory", _reportDirectory);
     enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs));
     VerifyJacocoCoverageForMaven(numberOfExecutionElements: 4, numberOfExecutionConfigurations: 3, verifyVersion: false, checkForPluginManagement: true, numOfJacocoPluginsInPluginManagement: 1);
     Assert.Equal(_warnings.Count, 0);
     Assert.Equal(_errors.Count, 0);
 }
 public void Maven_JaCoCo_EnableCodeCoverageWithFullClassNameFilters()
 {
     SetupMocks();
     LoadBuildFile(CodeCoverageTestConstants.PomXml);
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", "+:app.com.SampleTest,+:app.*.UtilTest,+:app2*,-:app.com.SampleTest,-:app.*.UtilTest,-:app3*");
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportdirectory", _reportDirectory);
     ccInputs.Add("reportbuildfile", _reportBuildFilePath);
     enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs));
     VerifyJacocoCoverageForMaven(includes: "**/app/com/SampleTest.class,**/app/*/UtilTest.class,**/app2*/**", excludes: "**/app/com/SampleTest.class,**/app/*/UtilTest.class,**/app3*/**", numOfIncludes: 3, numOfExcludes: 3, checkForPluginManagement: true);
     Assert.Equal(_warnings.Count, 0);
     Assert.Equal(_errors.Count, 0);
 }
 public void Maven_JaCoCo_EnableCodeCoverageWithNoIncludeExcludeFilters()
 {
     SetupMocks();
     LoadBuildFile(CodeCoverageTestConstants.PomXml);
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", "");
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportdirectory", _reportDirectory);
     enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs));
     VerifyJacocoCoverageForMaven(includes: string.Empty, excludes: string.Empty, numOfIncludes: 0, numOfExcludes: 0, checkForPluginManagement: true);
     Assert.Equal(_warnings.Count, 0);
     Assert.Equal(_errors.Count, 0);
 }
 public void Maven_JaCoCo_EnableCodeCoverageForInvalidBuildFile()
 {
     SetupMocks();
     _sampleBuildFilePath = Path.Combine(Path.GetTempPath(), "pomInvalid.xml");
     File.WriteAllText(_sampleBuildFilePath, @"This is not valid xml file contents");
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", _classFilter);
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportdirectory", _reportDirectory);
     ccInputs.Add("reportbuildfile", _reportBuildFilePath);
     Assert.Throws<XmlException>(() => enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs)));
 }
 public void EnableCodeCoverageForMavenJacocoThrowsWithNoReportDirectory()
 {
     SetupMocks();
     LoadBuildFile(CodeCoverageTestConstants.PomXml);
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", _classFilter);
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportbuildfile", _reportBuildFilePath);
     Assert.Throws<ArgumentException>(() => enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs)));
 }
 public void Maven_EnableCodeCoverageForJacocoWhenCodeCoverageIsIncorrectlyEnabled()
 {
     SetupMocks();
     // missing artifactId tag
     LoadBuildFile(CodeCoverageTestConstants.PomWithInvalidCCXml);
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", _classFilter);
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportdirectory", _reportDirectory);
     enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs));
     VerifyJacocoCoverageForMaven(numberOfExecutionElements: 4, verifyVersion: false);
     Assert.Equal(_warnings.Count, 0);
     Assert.Equal(_errors.Count, 0);
 }
 public void Maven_JaCoCo_EnableCodeCoverageForMultiModulePomWithCCEnabled()
 {
     SetupMocks();
     LoadBuildFile(CodeCoverageTestConstants.PomWithMultiModuleWithCCJacocoXml);
     _reportBuildFilePath = Path.Combine(Path.GetTempPath(), "MultiModuleReport.xml");
     var enableCodeCoverage = new CodeCoverageEnablerForJacocoMaven();
     enableCodeCoverage.Initialize(_hc);
     var ccInputs = new Dictionary<string, string>();
     ccInputs.Add("buildfile", _sampleBuildFilePath);
     ccInputs.Add("classfilter", _classFilter);
     ccInputs.Add("summaryfile", _summaryFile);
     ccInputs.Add("reportdirectory", _reportDirectory);
     ccInputs.Add("reportbuildfile", _reportBuildFilePath);
     enableCodeCoverage.EnableCodeCoverage(_ec.Object, new CodeCoverageEnablerInputs(_ec.Object, "Maven", ccInputs));
     VerifyJacocoCoverageForMaven(numberOfExecutionElements: 3, numberOfExecutionConfigurations: 3, verifyVersion: false);
     VerifyMultiModuleReports(expectedModelVersion: "4.0.0", expectedGroupId: "reports", expectedArtifactId: "report", expectedVersion: "1.0");
     Assert.Equal(_warnings.Count, 0);
     Assert.Equal(_errors.Count, 0);
 }