@Test // SONARJS-301 public void print_log_for_not_found_resource() throws InterruptedException { SonarRunner build = Tests.createSonarRunnerBuild() .setProjectDir(TestUtils.projectDir("lcov")) .setProjectKey("project") .setProjectName("project") .setProjectVersion("1.0") .setSourceDirs(".") .setProperty( "sonar.javascript.lcov.reportPath", TestUtils.file("projects/lcov/coverage-wrong-file-name.lcov").getAbsolutePath()) .setDebugLogs(true); BuildResult result = orchestrator.executeBuild(build); // Check that a log is printed String logs = result.getLogs(); assertThat(Pattern.compile("Analysing .*coverage-wrong-file-name\\.lcov").matcher(logs).find()) .isTrue(); assertThat( Pattern.compile("Default value of zero will be saved for file: .*file\\.js") .matcher(logs) .find()) .isTrue(); assertThat( Pattern.compile( "INFO.*Could not resolve 1 file paths in coverage-wrong-file-name\\.lcov, " + "first unresolved path: \\./wrong/fileName\\.js") .matcher(logs) .find()) .isTrue(); }
@Test public void LCOV_path_can_be_absolute() { SonarRunner build = Tests.createSonarRunnerBuild() .setProjectDir(TestUtils.projectDir("lcov")) .setProjectKey("project") .setProjectName("project") .setProjectVersion("1.0") .setSourceDirs(".") .setProperty( "sonar.javascript.lcov.reportPath", TestUtils.file("projects/lcov/coverage.lcov").getAbsolutePath()); orchestrator.executeBuild(build); assertThat(getProjectMeasure("lines_to_cover").getValue()).isEqualTo(4); assertThat(getProjectMeasure("uncovered_lines").getValue()).isEqualTo(1); assertThat(getProjectMeasure("conditions_to_cover").getValue()).isEqualTo(4); assertThat(getProjectMeasure("uncovered_conditions").getValue()).isEqualTo(2); }