use of org.sonar.go.plugin.GoCoverageReport.FileCoverage in project sonar-go by SonarSource.
the class GoCoverageReportTest method assertCoverGo.
void assertCoverGo(Path coverageFile, GoContext goContext, String absolutePath) throws IOException {
Coverage coverage = new Coverage(goContext);
GoCoverageReport.parse(coverageFile, coverage);
assertThat(coverage.fileMap.keySet()).containsExactlyInAnyOrder(absolutePath);
FileCoverage fileCoverage = coverage.fileMap.get(absolutePath);
assertThat(fileCoverage.lineMap.keySet()).containsExactlyInAnyOrder(3, 4, 5, 6, 7, 8);
assertThat(fileCoverage.lineMap.get(2)).isNull();
assertThat(fileCoverage.lineMap.get(3).hits).isEqualTo(1);
assertThat(fileCoverage.lineMap.get(4).hits).isEqualTo(2);
assertThat(fileCoverage.lineMap.get(5).hits).isEqualTo(2);
assertThat(fileCoverage.lineMap.get(6).hits).isEqualTo(0);
assertThat(fileCoverage.lineMap.get(7).hits).isEqualTo(0);
assertThat(fileCoverage.lineMap.get(8).hits).isEqualTo(0);
assertThat(fileCoverage.lineMap.get(9)).isNull();
}
use of org.sonar.go.plugin.GoCoverageReport.FileCoverage in project sonar-go by SonarSource.
the class GoCoverageReportTest method file_coverage.
@Test
void file_coverage() {
FileCoverage file = new FileCoverage(COVERAGE_DIR.resolve("cover.go").toString());
assertThat(file.lineMap.size()).isEqualTo(0);
file.add(new CoverageStat(2, "cover.go:4.11,6.3 1 3"));
file.add(new CoverageStat(3, "cover.go:6.3,8.3 1 0"));
assertThat(file.lineMap.keySet()).containsExactlyInAnyOrder(5, 6, 7);
assertThat(file.lineMap.get(4)).isNull();
assertThat(file.lineMap.get(5).hits).isEqualTo(3);
assertThat(file.lineMap.get(6).hits).isEqualTo(0);
assertThat(file.lineMap.get(7).hits).isEqualTo(0);
assertThat(file.lineMap.get(8)).isNull();
}
Aggregations