TraceSensor { public void execute(SensorContext context, Map<InputFile, Set<Integer>> executableLines, String[] traces) { for (String trace : traces) { FileSystem fs = context.fileSystem(); File report = fs.resolvePath(trace); if (report.isFile()) { new UnitTestsAnalyzer(report, executableLines).analyse(context); }else if(report.isDirectory()){ for (File reportFile:report.listFiles()){ new UnitTestsAnalyzer(reportFile, executableLines).analyse(context); } } else { LOG.info("Trace not found: '{}'", trace); } } }  void execute(SensorContext context, Map<InputFile, Set<Integer>> executableLines,  String[] traces); @Override String toString();  }
@Test public void report_not_found() throws Exception { sensor.execute(context, linesOfCode, new String[] { "/fake/path/trace.txt" }); assertThat(context.lineHits("moduleKey:file1.js", 1)).isNull(); }
@Test public void test_overall_coverage() { sensor.execute(context, linesOfCode, new String[] { "TraceSensorTest/trace.txt" }); Integer[] file1Expected = { 3, 3, 1, null }; Integer[] file2Expected = { 5, 5, null, null }; assertThat(context.conditions("moduleKey:file1.esql", 1)).isEqualTo(1); assertThat(context.coveredConditions("moduleKey:file1.esql", 2)).isEqualTo(0); assertThat(context.lineHits("moduleKey:file1.esql", 3)).isEqualTo(0); assertThat(context.lineHits("moduleKey:file1.esql", 4)).isEqualTo(1); }