Search in sources :

Example 1 with Coverage

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();
}
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 Coverage

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

Aggregations

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