From 69065a0dee5e6a4cd2ca414125edd421d4fe0a4c Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 17 May 2016 11:42:45 +0200 Subject: Improve unit test coverage --- .../mediumtest/measures/MeasuresMediumTest.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sonar-scanner-engine') diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java index 0affd4dad8e..00e7ee34ab5 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/mediumtest/measures/MeasuresMediumTest.java @@ -125,4 +125,30 @@ public class MeasuresMediumTest { .contains(tuple("lines", 3), tuple("ncloc", 2)); } + @Test + public void lineMeasures() throws IOException { + File xooFile = new File(srcDir, "sample.xoo"); + FileUtils.write(xooFile, "Sample xoo\n\n\ncontent"); + + File lineMeasures = new File(srcDir, "sample.xoo.linemeasures"); + FileUtils.write(lineMeasures, "ncloc_data:1=1;2=0;4=1"); + + TaskResult result = tester.newTask() + .properties(ImmutableMap.builder() + .put("sonar.task", "scan") + .put("sonar.projectBaseDir", baseDir.getAbsolutePath()) + .put("sonar.projectKey", "com.foo.project") + .put("sonar.projectName", "Foo Project") + .put("sonar.projectVersion", "1.0-SNAPSHOT") + .put("sonar.projectDescription", "Description of Foo Project") + .put("sonar.sources", "src") + .build()) + .start(); + + Map> allMeasures = result.allMeasures(); + + assertThat(allMeasures.get("com.foo.project:src/sample.xoo")).extracting("metricKey", "intValue.value", "stringValue.value") + .containsExactly(tuple("lines", 4, ""), tuple("ncloc_data", 0, "1=1;4=1")); + } + } -- cgit v1.2.3