@Test public void upload_reports() throws IOException { Path baseDir = COVERAGE_DIR.toAbsolutePath(); SensorContextTester context = SensorContextTester.create(baseDir); context.setSettings(new MapSettings()); context.settings().setProperty("sonar.go.coverage.reportPaths", "coverage.relative.out"); Path goFilePath = baseDir.resolve("cover.go"); String content = new String(Files.readAllBytes(goFilePath), UTF_8); context.fileSystem().add(TestInputFileBuilder.create("moduleKey", baseDir.toFile(), goFilePath.toFile()) .setLanguage("go") .setType(InputFile.Type.MAIN) .initMetadata(content) .setContents(content) .build()); GoPathContext goContext = new GoPathContext(File.separatorChar, File.pathSeparator, baseDir.toString()); GoCoverSensor sensor = new GoCoverSensor(); sensor.execute(context, goContext); String fileKey = "moduleKey:cover.go"; assertThat(context.lineHits(fileKey, 3)).isNull(); assertThat(context.lineHits(fileKey, 4)).isEqualTo(1); assertThat(context.lineHits(fileKey, 5)).isEqualTo(2); assertThat(context.conditions(fileKey, 5)).isNull(); assertThat(context.coveredConditions(fileKey, 5)).isNull(); assertThat(context.lineHits(fileKey, 6)).isEqualTo(0); assertThat(context.lineHits(fileKey, 7)).isEqualTo(0); assertThat(context.lineHits(fileKey, 8)).isNull(); }
@Override public void execute(SensorContext context) { execute(context, GoPathContext.DEFAULT); }
GoCoverSensor implements Sensor { @Override public void execute(SensorContext context) { execute(context, GoPathContext.DEFAULT); } }
GoCoverSensor implements Sensor { @Override public void execute(SensorContext context) { execute(context, GoPathContext.DEFAULT); }  }
GoCoverSensor implements Sensor { @Override public void execute(SensorContext context) { execute(context, GoPathContext.DEFAULT); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); }
GoCoverSensor implements Sensor { @Override public void execute(SensorContext context) { execute(context, GoPathContext.DEFAULT); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); static final String REPORT_PATH_KEY; }