@Test public void testFilesCoverage() throws IOException { Path baseDir = COVERAGE_DIR.toAbsolutePath(); Path reportPath = baseDir.resolve("scoverage.xml"); SensorContextTester context = getSensorContext(reportPath.toString(), "file1.scala", "file2.scala"); new ScoverageSensor().execute(context); String fileKey1 = MODULE_KEY + ":file1.scala"; String fileKey2 = MODULE_KEY + ":file2.scala"; assertThat(context.lineHits(fileKey1, 5)).isNull(); assertThat(context.lineHits(fileKey1, 6)).isEqualTo(0); assertThat(context.lineHits(fileKey1, 7)).isEqualTo(1); assertThat(context.lineHits(fileKey1, 8)).isEqualTo(0); assertThat(context.lineHits(fileKey1, 9)).isNull(); assertThat(context.lineHits(fileKey2, 5)).isEqualTo(1); assertThat(context.lineHits(fileKey2, 6)).isNull(); assertThat(context.lineHits(fileKey2, 7)).isEqualTo(2); assertThat(context.lineHits(fileKey2, 8)).isNull(); assertThat(context.lineHits(fileKey2, 9)).isEqualTo(0); }
@Override public void execute(SensorContext context) { List<File> reportFiles = getReportFiles(context); if (reportFiles.isEmpty()) { return; } Set<String> unresolvedInputFile = new HashSet<>(); for (File f : reportFiles) { LOG.info("Importing coverage from {}", f.getPath()); try(InputStream in = new FileInputStream(f)){ readReportFile(in, context, unresolvedInputFile); } catch (IOException | XMLStreamException | NumberFormatException e) { LOG.error("File '{}' can't be read. " + e.toString(), f, e); } } logUnresolvedInputFiles(unresolvedInputFile); }
ScoverageSensor implements Sensor { @Override public void execute(SensorContext context) { List<File> reportFiles = getReportFiles(context); if (reportFiles.isEmpty()) { return; } Set<String> unresolvedInputFile = new HashSet<>(); for (File f : reportFiles) { LOG.info("Importing coverage from {}", f.getPath()); try(InputStream in = new FileInputStream(f)){ readReportFile(in, context, unresolvedInputFile); } catch (IOException | XMLStreamException | NumberFormatException e) { LOG.error("File '{}' can't be read. " + e.toString(), f, e); } } logUnresolvedInputFiles(unresolvedInputFile); } }
ScoverageSensor implements Sensor { @Override public void execute(SensorContext context) { List<File> reportFiles = getReportFiles(context); if (reportFiles.isEmpty()) { return; } Set<String> unresolvedInputFile = new HashSet<>(); for (File f : reportFiles) { LOG.info("Importing coverage from {}", f.getPath()); try(InputStream in = new FileInputStream(f)){ readReportFile(in, context, unresolvedInputFile); } catch (IOException | XMLStreamException | NumberFormatException e) { LOG.error("File '{}' can't be read. " + e.toString(), f, e); } } logUnresolvedInputFiles(unresolvedInputFile); }  }
ScoverageSensor implements Sensor { @Override public void execute(SensorContext context) { List<File> reportFiles = getReportFiles(context); if (reportFiles.isEmpty()) { return; } Set<String> unresolvedInputFile = new HashSet<>(); for (File f : reportFiles) { LOG.info("Importing coverage from {}", f.getPath()); try(InputStream in = new FileInputStream(f)){ readReportFile(in, context, unresolvedInputFile); } catch (IOException | XMLStreamException | NumberFormatException e) { LOG.error("File '{}' can't be read. " + e.toString(), f, e); } } logUnresolvedInputFiles(unresolvedInputFile); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); }
ScoverageSensor implements Sensor { @Override public void execute(SensorContext context) { List<File> reportFiles = getReportFiles(context); if (reportFiles.isEmpty()) { return; } Set<String> unresolvedInputFile = new HashSet<>(); for (File f : reportFiles) { LOG.info("Importing coverage from {}", f.getPath()); try(InputStream in = new FileInputStream(f)){ readReportFile(in, context, unresolvedInputFile); } catch (IOException | XMLStreamException | NumberFormatException e) { LOG.error("File '{}' can't be read. " + e.toString(), f, e); } } logUnresolvedInputFiles(unresolvedInputFile); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }