} else {
throw new IllegalArgumentException("Executable lines can only be saved on files");
}
- } else {
- reportPublisher.getWriter().appendComponentMeasure(((DefaultInputComponent) component).scannerId(), toReportMeasure(measure));
}
+ reportPublisher.getWriter().appendComponentMeasure(((DefaultInputComponent) component).scannerId(), toReportMeasure(measure));
}
public static ScannerReport.Measure toReportMeasure(DefaultMeasure measureToSave) {
import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.scanner.mediumtest.AnalysisResult;
import org.sonar.scanner.mediumtest.ScannerMediumTester;
+import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.xoo.XooPlugin;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForClassTypes.tuple;
public class CoverageMediumTest {
assertThat(result.coverageFor(file, 3).getHits()).isFalse();
assertThat(result.coverageFor(file, 4)).isNull();
+
+ assertThat(result.allMeasures().get(file.key()))
+ .extracting(ScannerReport.Measure::getMetricKey, m -> m.getStringValue().getValue())
+ .contains(tuple("executable_lines_data", "2=1;3=1;4=0"));
}
// SONAR-11641
File measuresFile = new File(srcDir, "sample.xoo.measures");
File coverageFile = new File(srcDir, "sample.xoo.coverage");
FileUtils.write(xooFile, "function foo() {\n if (a && b) {\nalert('hello');\n}\n}", StandardCharsets.UTF_8);
- FileUtils.write(measuresFile, "# The code analyzer disagree with the coverage tool and consider some lines to be executable\nexecutable_lines_data:2=1;3=1;4=0", StandardCharsets.UTF_8);
+ FileUtils.write(measuresFile, "# The code analyzer disagree with the coverage tool and consider some lines to be executable\nexecutable_lines_data:2=1;3=1;4=0",
+ StandardCharsets.UTF_8);
FileUtils.write(coverageFile, "# No lines to cover in this file according to the coverage tool", StandardCharsets.UTF_8);
AnalysisResult result = tester.newAnalysis()