Search in sources :

Example 1 with FileCoverage

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();
}
Also used : LineCoverage(org.sonar.go.plugin.GoCoverageReport.LineCoverage) Coverage(org.sonar.go.plugin.GoCoverageReport.Coverage) FileCoverage(org.sonar.go.plugin.GoCoverageReport.FileCoverage) FileCoverage(org.sonar.go.plugin.GoCoverageReport.FileCoverage)

Example 2 with FileCoverage

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();
}
Also used : CoverageStat(org.sonar.go.plugin.GoCoverageReport.CoverageStat) FileCoverage(org.sonar.go.plugin.GoCoverageReport.FileCoverage) Test(org.junit.jupiter.api.Test)

Aggregations

FileCoverage (org.sonar.go.plugin.GoCoverageReport.FileCoverage)2 Test (org.junit.jupiter.api.Test)1 Coverage (org.sonar.go.plugin.GoCoverageReport.Coverage)1 CoverageStat (org.sonar.go.plugin.GoCoverageReport.CoverageStat)1 LineCoverage (org.sonar.go.plugin.GoCoverageReport.LineCoverage)1