use of org.sonar.go.plugin.GoCoverageReport.Coverage 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.Coverage in project sonar-go by SonarSource.
the class GoCoverageReportTest method coverage.
@Test
void coverage() {
GoContext linuxContext = new GoContext('/', "/home/paul/go");
Coverage coverage = new Coverage(linuxContext);
coverage.add(new CoverageStat(2, "main.go:2.2,2.5 1 1"));
coverage.add(new CoverageStat(3, "main.go:4.2,4.7 1 0"));
coverage.add(new CoverageStat(4, "other.go:3.2,4.12 1 1"));
assertThat(coverage.fileMap.keySet()).containsExactlyInAnyOrder("/home/paul/go/main.go", "/home/paul/go/other.go");
assertThat(coverage.fileMap.get("/home/paul/go/main.go").lineMap.keySet()).containsExactlyInAnyOrder(2, 4);
assertThat(coverage.fileMap.get("/home/paul/go/other.go").lineMap.keySet()).containsExactlyInAnyOrder(3, 4);
}
Aggregations