]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8284 Remove overall/IT coverage data from scanner report
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 17 Oct 2016 14:31:39 +0000 (16:31 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 18 Oct 2016 14:00:26 +0000 (16:00 +0200)
12 files changed:
it/it-tests/src/test/java/it/test/CoverageTest.java
it/it-tests/src/test/resources/test/CoverageTest/it_coverage-expected.json
it/it-tests/src/test/resources/test/CoverageTest/ut_and_it_coverage-expected.json
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReader.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/source/CoverageLineReaderTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/PersistFileSourcesStepTest.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/report/CoveragePublisher.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/CoveragePublisherTest.java
sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java
sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportWriterTest.java

index 106cd9ffbce7a5497d61f27a931a10bbe8745ed8..65368cc2f9f913e079217c3f3b08c656358b183a 100644 (file)
@@ -55,7 +55,7 @@ public class CoverageTest {
   }
 
   @Test
-  public void unit_test_coverage() throws Exception {
+  public void coverage() throws Exception {
     orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-ut-coverage")));
 
     Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("sample-ut-coverage", ALL_COVERAGE_METRICS));
@@ -86,7 +86,7 @@ public class CoverageTest {
   }
 
   @Test
-  public void unit_test_coverage_no_condition() throws Exception {
+  public void coverage_no_condition() throws Exception {
     orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-ut-coverage-no-condition")));
 
     Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("sample-ut-coverage", ALL_COVERAGE_METRICS));
@@ -111,19 +111,22 @@ public class CoverageTest {
   }
 
   @Test
-  public void it_coverage() throws Exception {
+  public void it_coverage_imported_as_coverage() throws Exception {
     orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-it-coverage")));
 
     Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("sample-it-coverage", ALL_COVERAGE_METRICS));
-    assertThat(project.getMeasureValue("coverage")).isNull();
 
-    assertThat(project.getMeasureValue("it_line_coverage")).isEqualTo(50.0);
-    assertThat(project.getMeasureValue("it_lines_to_cover")).isEqualTo(4);
-    assertThat(project.getMeasureValue("it_uncovered_lines")).isEqualTo(2);
-    assertThat(project.getMeasureValue("it_branch_coverage")).isEqualTo(50.0);
-    assertThat(project.getMeasureValue("it_conditions_to_cover")).isEqualTo(2);
-    assertThat(project.getMeasureValue("it_uncovered_conditions")).isEqualTo(1);
-    assertThat(project.getMeasureValue("it_coverage")).isEqualTo(50.0);
+    // Since SQ 6.2 all coverage reports are merged as coverage
+
+    assertThat(project.getMeasureValue("line_coverage")).isEqualTo(50.0);
+    assertThat(project.getMeasureValue("lines_to_cover")).isEqualTo(4);
+    assertThat(project.getMeasureValue("uncovered_lines")).isEqualTo(2);
+    assertThat(project.getMeasureValue("branch_coverage")).isEqualTo(50.0);
+    assertThat(project.getMeasureValue("conditions_to_cover")).isEqualTo(2);
+    assertThat(project.getMeasureValue("uncovered_conditions")).isEqualTo(1);
+    assertThat(project.getMeasureValue("coverage")).isEqualTo(50.0);
+
+    assertThat(project.getMeasureValue("it_coverage")).isNull();
 
     assertThat(project.getMeasureValue("overall_coverage")).isNull();
 
@@ -135,9 +138,11 @@ public class CoverageTest {
   }
 
   @Test
-  public void ut_and_it_coverage() throws Exception {
+  public void ut_and_it_coverage_merged_in_coverage() throws Exception {
     orchestrator.executeBuilds(SonarScanner.create(projectDir("testing/xoo-sample-overall-coverage")));
 
+    // Since SQ 6.2 all coverage reports are merged as coverage
+
     Resource project = orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics("sample-overall-coverage", ALL_COVERAGE_METRICS));
     assertThat(project.getMeasureValue("line_coverage")).isEqualTo(50.0);
     assertThat(project.getMeasureValue("lines_to_cover")).isEqualTo(4);
@@ -147,21 +152,9 @@ public class CoverageTest {
     assertThat(project.getMeasureValue("uncovered_conditions")).isEqualTo(3);
     assertThat(project.getMeasureValue("coverage")).isEqualTo(37.5);
 
-    assertThat(project.getMeasureValue("it_line_coverage")).isEqualTo(50.0);
-    assertThat(project.getMeasureValue("it_lines_to_cover")).isEqualTo(4);
-    assertThat(project.getMeasureValue("it_uncovered_lines")).isEqualTo(2);
-    assertThat(project.getMeasureValue("it_branch_coverage")).isEqualTo(25.0);
-    assertThat(project.getMeasureValue("it_conditions_to_cover")).isEqualTo(4);
-    assertThat(project.getMeasureValue("it_uncovered_conditions")).isEqualTo(3);
-    assertThat(project.getMeasureValue("it_coverage")).isEqualTo(37.5);
-
-    assertThat(project.getMeasureValue("overall_line_coverage")).isEqualTo(75.0);
-    assertThat(project.getMeasureValue("overall_lines_to_cover")).isEqualTo(4);
-    assertThat(project.getMeasureValue("overall_uncovered_lines")).isEqualTo(1);
-    assertThat(project.getMeasureValue("overall_branch_coverage")).isEqualTo(50.0);
-    assertThat(project.getMeasureValue("overall_conditions_to_cover")).isEqualTo(4);
-    assertThat(project.getMeasureValue("overall_uncovered_conditions")).isEqualTo(2);
-    assertThat(project.getMeasureValue("overall_coverage")).isEqualTo(62.5);
+    assertThat(project.getMeasureValue("it_coverage")).isNull();
+
+    assertThat(project.getMeasureValue("overall_coverage")).isNull();
 
     String coverage = cleanupScmAndDuplication(orchestrator.getServer().adminWsClient().get("api/sources/lines", "key", "sample-overall-coverage:src/main/xoo/sample/Sample.xoo"));
     // Use strict checking to be sure no extra coverage is present
index e18e570ff1edf44ee7c7ecba41dbfb1997223746..25e10e11bd35da7de2f0c9c5fe32a5abcae47455 100644 (file)
@@ -2,77 +2,77 @@
   "sources": [
     {
       "line": 1,
-      "code": "package sample;",
+      "code": "package sample;"
     },
     {
       "line": 2,
-      "code": "",
+      "code": ""
     },
     {
       "line": 3,
-      "code": "public class Sample {",
+      "code": "public class Sample {"
     },
     {
       "line": 4,
-      "code": "\t",
+      "code": "\t"
     },
     {
       "line": 5,
-      "code": "\tpublic Sample(int i) {",
+      "code": "\tpublic Sample(int i) {"
     },
     {
       "line": 6,
       "code": "\t\tint j = i++;",
-      "itLineHits": 1
+      "utLineHits": 1
     },
     {
       "line": 7,
-      "code": "\t}",
+      "code": "\t}"
     },
     {
       "line": 8,
-      "code": "\t",
+      "code": "\t"
     },
     {
       "line": 9,
-      "code": "\tprivate String myMethod() {",
+      "code": "\tprivate String myMethod() {"
     },
     {
       "line": 10,
       "code": "\t\tif (foo == bar) {",
-      "itLineHits": 0,
-      "itConditions": 2,
-      "itCoveredConditions": 1
+      "utLineHits": 0,
+      "utConditions": 2,
+      "utCoveredConditions": 1
     },
     {
       "line": 11,
       "code": "\t\t\treturn \"hello\";",
-      "itLineHits": 1
+      "utLineHits": 1
     },
     {
       "line": 12,
-      "code": "\t\t} else {",
+      "code": "\t\t} else {"
     },
     {
       "line": 13,
       "code": "\t\t\tthrow new IllegalStateException();",
-      "itLineHits": 0
+      "utLineHits": 0
     },
     {
       "line": 14,
-      "code": "\t\t}",
+      "code": "\t\t}"
     },
     {
       "line": 15,
-      "code": "\t}",
+      "code": "\t}"
     },
     {
       "line": 16,
-      "code": "}",
+      "code": "}"
     },
     {
       "line": 17,
-      "code": "",
+      "code": ""
     }
   ]
 }
index 9d12abbba9c6e8a315b1b4c2c448d79b791d1a15..59ca44b2acbddb3061f6e4a24aff7c101ca5eeab 100644 (file)
@@ -2,83 +2,77 @@
   "sources": [
     {
       "line": 1,
-      "code": "package sample;",
+      "code": "package sample;"
     },
     {
       "line": 2,
-      "code": "",
+      "code": ""
     },
     {
       "line": 3,
-      "code": "public class Sample {",
+      "code": "public class Sample {"
     },
     {
       "line": 4,
-      "code": "\t",
+      "code": "\t"
     },
     {
       "line": 5,
-      "code": "\tpublic Sample(int i) {",
+      "code": "\tpublic Sample(int i) {"
     },
     {
       "line": 6,
       "code": "\t\tint j = i++;",
-      "utLineHits": 1,
-      "itLineHits": 1
+      "utLineHits": 1
     },
     {
       "line": 7,
-      "code": "\t}",
+      "code": "\t}"
     },
     {
       "line": 8,
-      "code": "\t",
+      "code": "\t"
     },
     {
       "line": 9,
-      "code": "\tprivate String myMethod() {",
+      "code": "\tprivate String myMethod() {"
     },
     {
       "line": 10,
       "code": "\t\tif (foo == bar &amp;&amp; biz &gt; 1) {",
       "utLineHits": 0,
       "utConditions": 4,
-      "utCoveredConditions": 1,
-      "itLineHits": 0,
-      "itConditions": 4,
-      "itCoveredConditions": 1
+      "utCoveredConditions": 1
     },
     {
       "line": 11,
       "code": "\t\t\treturn \"hello\";",
-      "utLineHits": 1,
-      "itLineHits": 0
+      "utLineHits": 1
     },
     {
       "line": 12,
-      "code": "\t\t} else {",
+      "code": "\t\t} else {"
     },
     {
       "line": 13,
       "code": "\t\t\tthrow new IllegalStateException();",
-      "utLineHits": 0,
-      "itLineHits": 1
+      "utLineHits": 1
     },
     {
       "line": 14,
-      "code": "\t\t}",
+      "code": "\t\t}"
     },
     {
       "line": 15,
-      "code": "\t}",
+      "code": "\t}"
     },
     {
       "line": 16,
-      "code": "}",
+      "code": "}"
     },
     {
       "line": 17,
-      "code": "",
+      "code": ""
     }
   ]
 
index a54a20f6e8af96b65ec5c631be706b43bc8a31fc..1f3fdedbf5fb72ca092c79a7eacea664a07cd4b5 100644 (file)
@@ -23,11 +23,8 @@ import java.util.Iterator;
 import javax.annotation.CheckForNull;
 import org.sonar.db.protobuf.DbFileSources;
 import org.sonar.scanner.protocol.output.ScannerReport;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasItCoveredConditionsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasItHitsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasOverallCoveredConditionsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasUtCoveredConditionsCase;
-import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasUtHitsCase;
+import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasCoveredConditionsCase;
+import org.sonar.scanner.protocol.output.ScannerReport.LineCoverage.HasHitsCase;
 
 public class CoverageLineReader implements LineReader {
 
@@ -43,39 +40,28 @@ public class CoverageLineReader implements LineReader {
     ScannerReport.LineCoverage reportCoverage = getNextLineCoverageIfMatchLine(lineBuilder.getLine());
     if (reportCoverage != null) {
       processUnitTest(lineBuilder, reportCoverage);
-      processIntegrationTest(lineBuilder, reportCoverage);
       processOverallTest(lineBuilder, reportCoverage);
       coverage = null;
     }
   }
 
   private static void processUnitTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.LineCoverage reportCoverage) {
-    if (reportCoverage.getHasUtHitsCase() == HasUtHitsCase.UT_HITS) {
-      lineBuilder.setUtLineHits(reportCoverage.getUtHits() ? 1 : 0);
+    if (reportCoverage.getHasHitsCase() == HasHitsCase.HITS) {
+      lineBuilder.setUtLineHits(reportCoverage.getHits() ? 1 : 0);
     }
-    if (reportCoverage.getHasUtCoveredConditionsCase() == HasUtCoveredConditionsCase.UT_COVERED_CONDITIONS) {
+    if (reportCoverage.getHasCoveredConditionsCase() == HasCoveredConditionsCase.COVERED_CONDITIONS) {
       lineBuilder.setUtConditions(reportCoverage.getConditions());
-      lineBuilder.setUtCoveredConditions(reportCoverage.getUtCoveredConditions());
-    }
-  }
-
-  private static void processIntegrationTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.LineCoverage reportCoverage) {
-    if (reportCoverage.getHasItHitsCase() == HasItHitsCase.IT_HITS) {
-      lineBuilder.setItLineHits(reportCoverage.getItHits() ? 1 : 0);
-    }
-    if (reportCoverage.getHasItCoveredConditionsCase() == HasItCoveredConditionsCase.IT_COVERED_CONDITIONS) {
-      lineBuilder.setItConditions(reportCoverage.getConditions());
-      lineBuilder.setItCoveredConditions(reportCoverage.getItCoveredConditions());
+      lineBuilder.setUtCoveredConditions(reportCoverage.getCoveredConditions());
     }
   }
 
   private static void processOverallTest(DbFileSources.Line.Builder lineBuilder, ScannerReport.LineCoverage reportCoverage) {
-    if (reportCoverage.getHasUtHitsCase() == HasUtHitsCase.UT_HITS || reportCoverage.getHasItHitsCase() == HasItHitsCase.IT_HITS) {
-      lineBuilder.setOverallLineHits((reportCoverage.getUtHits() || reportCoverage.getItHits()) ? 1 : 0);
+    if (reportCoverage.getHasHitsCase() == HasHitsCase.HITS) {
+      lineBuilder.setOverallLineHits(reportCoverage.getHits() ? 1 : 0);
     }
-    if (reportCoverage.getHasOverallCoveredConditionsCase() == HasOverallCoveredConditionsCase.OVERALL_COVERED_CONDITIONS) {
+    if (reportCoverage.getHasCoveredConditionsCase() == HasCoveredConditionsCase.COVERED_CONDITIONS) {
       lineBuilder.setOverallConditions(reportCoverage.getConditions());
-      lineBuilder.setOverallCoveredConditions(reportCoverage.getOverallCoveredConditions());
+      lineBuilder.setOverallCoveredConditions(reportCoverage.getCoveredConditions());
     }
   }
 
index dede32111a58afa4b0f25dd83d3b8f3312e57756..7a756748e8d25d0d07d5fd9255bc275361a59a23 100644 (file)
@@ -34,11 +34,8 @@ public class CoverageLineReaderTest {
     CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
       .setConditions(10)
-      .setUtHits(true)
-      .setUtCoveredConditions(2)
-      .setItHits(true)
-      .setItCoveredConditions(3)
-      .setOverallCoveredConditions(4)
+      .setHits(true)
+      .setCoveredConditions(2)
       .build()).iterator());
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -46,11 +43,6 @@ public class CoverageLineReaderTest {
 
     assertThat(lineBuilder.getUtLineHits()).isEqualTo(1);
     assertThat(lineBuilder.getUtConditions()).isEqualTo(10);
-    assertThat(lineBuilder.getItLineHits()).isEqualTo(1);
-    assertThat(lineBuilder.getItConditions()).isEqualTo(10);
-    assertThat(lineBuilder.getItCoveredConditions()).isEqualTo(3);
-    assertThat(lineBuilder.getOverallLineHits()).isEqualTo(1);
-    assertThat(lineBuilder.getOverallConditions()).isEqualTo(10);
   }
 
   // Some tools are only able to report condition coverage
@@ -59,8 +51,7 @@ public class CoverageLineReaderTest {
     CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
       .setConditions(10)
-      .setUtCoveredConditions(2)
-      .setItCoveredConditions(3)
+      .setCoveredConditions(2)
       .build()).iterator());
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -69,10 +60,9 @@ public class CoverageLineReaderTest {
     assertThat(lineBuilder.hasUtLineHits()).isFalse();
     assertThat(lineBuilder.getUtConditions()).isEqualTo(10);
     assertThat(lineBuilder.hasItLineHits()).isFalse();
-    assertThat(lineBuilder.getItConditions()).isEqualTo(10);
-    assertThat(lineBuilder.getItCoveredConditions()).isEqualTo(3);
     assertThat(lineBuilder.hasOverallLineHits()).isFalse();
-    assertThat(lineBuilder.hasOverallConditions()).isFalse();
+    assertThat(lineBuilder.hasOverallConditions()).isTrue();
+    assertThat(lineBuilder.getOverallConditions()).isEqualTo(10);
   }
 
   @Test
@@ -80,8 +70,8 @@ public class CoverageLineReaderTest {
     CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
       .setConditions(10)
-      .setUtHits(true)
-      .setUtCoveredConditions(2)
+      .setHits(true)
+      .setCoveredConditions(2)
       .build()).iterator());
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -89,40 +79,20 @@ public class CoverageLineReaderTest {
 
     assertThat(lineBuilder.getUtLineHits()).isEqualTo(1);
     assertThat(lineBuilder.getUtConditions()).isEqualTo(10);
+    assertThat(lineBuilder.getUtCoveredConditions()).isEqualTo(2);
     assertThat(lineBuilder.hasItLineHits()).isFalse();
     assertThat(lineBuilder.hasItConditions()).isFalse();
     assertThat(lineBuilder.hasItCoveredConditions()).isFalse();
     assertThat(lineBuilder.getOverallLineHits()).isEqualTo(1);
-    assertThat(lineBuilder.hasOverallCoveredConditions()).isFalse();
-  }
-
-  @Test
-  public void set_coverage_only_it() {
-    CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
-      .setLine(1)
-      .setConditions(10)
-      .setItHits(true)
-      .setItCoveredConditions(3)
-      .build()).iterator());
-
-    DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
-    computeCoverageLine.read(lineBuilder);
-
-    assertThat(lineBuilder.hasUtLineHits()).isFalse();
-    assertThat(lineBuilder.hasUtConditions()).isFalse();
-    assertThat(lineBuilder.getItLineHits()).isEqualTo(1);
-    assertThat(lineBuilder.getItConditions()).isEqualTo(10);
-    assertThat(lineBuilder.getItCoveredConditions()).isEqualTo(3);
-    assertThat(lineBuilder.getOverallLineHits()).isEqualTo(1);
-    assertThat(lineBuilder.hasOverallConditions()).isFalse();
+    assertThat(lineBuilder.hasOverallCoveredConditions()).isTrue();
+    assertThat(lineBuilder.getOverallCoveredConditions()).isEqualTo(2);
   }
 
   @Test
   public void set_coverage_on_uncovered_lines() {
     CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
-      .setUtHits(false)
-      .setItHits(false)
+      .setHits(false)
       .build()).iterator());
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -130,8 +100,6 @@ public class CoverageLineReaderTest {
 
     assertThat(lineBuilder.hasUtLineHits()).isTrue();
     assertThat(lineBuilder.getUtLineHits()).isEqualTo(0);
-    assertThat(lineBuilder.hasItLineHits()).isTrue();
-    assertThat(lineBuilder.getItLineHits()).isEqualTo(0);
     assertThat(lineBuilder.hasOverallLineHits()).isTrue();
     assertThat(lineBuilder.getOverallLineHits()).isEqualTo(0);
   }
@@ -140,7 +108,7 @@ public class CoverageLineReaderTest {
   public void set_overall_line_hits_with_only_ut() {
     CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
-      .setUtHits(true)
+      .setHits(true)
       .build()).iterator());
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -153,7 +121,7 @@ public class CoverageLineReaderTest {
   public void set_overall_line_hits_with_only_it() {
     CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
-      .setItHits(true)
+      .setHits(true)
       .build()).iterator());
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -166,8 +134,7 @@ public class CoverageLineReaderTest {
   public void set_overall_line_hits_with_ut_and_it() {
     CoverageLineReader computeCoverageLine = new CoverageLineReader(newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
-      .setUtHits(true)
-      .setItHits(true)
+      .setHits(true)
       .build()).iterator());
 
     DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
@@ -198,11 +165,8 @@ public class CoverageLineReaderTest {
       ScannerReport.LineCoverage.newBuilder()
         .setLine(1)
         .setConditions(10)
-        .setUtHits(true)
-        .setUtCoveredConditions(2)
-        .setItHits(true)
-        .setItCoveredConditions(3)
-        .setOverallCoveredConditions(4)
+        .setHits(true)
+        .setCoveredConditions(2)
         .build()
     // No coverage info on line 2
     ).iterator());
@@ -225,11 +189,8 @@ public class CoverageLineReaderTest {
       ScannerReport.LineCoverage.newBuilder()
         .setLine(1)
         .setConditions(10)
-        .setUtHits(true)
-        .setUtCoveredConditions(2)
-        .setItHits(true)
-        .setItCoveredConditions(3)
-        .setOverallCoveredConditions(4)
+        .setHits(true)
+        .setCoveredConditions(2)
         .build()
     // No coverage info on line 2
     ).iterator());
index a203c3ea4113356875499cdeca7c218d30827889..387241fce2ff47fe96ed0104a2aeeb07043957a7 100644 (file)
@@ -35,9 +35,9 @@ import org.sonar.scanner.protocol.output.ScannerReport;
 import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
 import org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType;
 import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReaderRule;
-import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
 import org.sonar.server.computation.task.projectanalysis.component.ReportComponent;
+import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolderRule;
 import org.sonar.server.computation.task.projectanalysis.duplication.Duplicate;
 import org.sonar.server.computation.task.projectanalysis.duplication.Duplication;
 import org.sonar.server.computation.task.projectanalysis.duplication.DuplicationRepositoryRule;
@@ -138,11 +138,8 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     reportReader.putCoverage(FILE_REF, newArrayList(ScannerReport.LineCoverage.newBuilder()
       .setLine(1)
       .setConditions(10)
-      .setUtHits(true)
-      .setUtCoveredConditions(2)
-      .setItHits(true)
-      .setItCoveredConditions(3)
-      .setOverallCoveredConditions(4)
+      .setHits(true)
+      .setCoveredConditions(2)
       .build()));
 
     underTest.execute();
@@ -156,12 +153,6 @@ public class PersistFileSourcesStepTest extends BaseStepTest {
     assertThat(data.getLines(0).getUtLineHits()).isEqualTo(1);
     assertThat(data.getLines(0).getUtConditions()).isEqualTo(10);
     assertThat(data.getLines(0).getUtCoveredConditions()).isEqualTo(2);
-    assertThat(data.getLines(0).hasItLineHits()).isTrue();
-    assertThat(data.getLines(0).getItConditions()).isEqualTo(10);
-    assertThat(data.getLines(0).getItCoveredConditions()).isEqualTo(3);
-    assertThat(data.getLines(0).getOverallLineHits()).isEqualTo(1);
-    assertThat(data.getLines(0).getOverallConditions()).isEqualTo(10);
-    assertThat(data.getLines(0).getOverallCoveredConditions()).isEqualTo(4);
   }
 
   @Test
index cf17785dab8411a189d6f7d8c59631f0d60b1124..ba776070fa5fe844e9ca62d4cecbe0aa6bd4c988 100644 (file)
@@ -56,57 +56,11 @@ public class CoveragePublisher implements ReportPublisherStep {
 
       int lineCount = ((InputFile) resource.inputComponent()).lines();
       applyLineMeasure(resource.key(), lineCount, CoreMetrics.COVERAGE_LINE_HITS_DATA_KEY, coveragePerLine,
-        new MeasureOperation() {
-          @Override
-          public void apply(String value, LineCoverage.Builder builder) {
-            builder.setUtHits(Integer.parseInt(value) > 0);
-          }
-        });
-      applyLineMeasure(resource.key(), lineCount, CoreMetrics.IT_COVERAGE_LINE_HITS_DATA_KEY, coveragePerLine,
-        new MeasureOperation() {
-          @Override
-          public void apply(String value, LineCoverage.Builder builder) {
-            builder.setItHits(Integer.parseInt(value) > 0);
-          }
-        });
-      // Just in case we have only IT and no UT, we first take conditions from ITs, then from UTs (UTs will override ITs).
-      // Note that it would be very strange (and unsupported in scanner report) to have ITs and UTs don't report the same number of
-      // conditions. Not even talking about overall conditions...
-      applyLineMeasure(resource.key(), lineCount, CoreMetrics.IT_CONDITIONS_BY_LINE_KEY, coveragePerLine,
-        new MeasureOperation() {
-          @Override
-          public void apply(String value, LineCoverage.Builder builder) {
-            builder.setConditions(Integer.parseInt(value));
-          }
-        });
+        (value, builder) -> builder.setHits(Integer.parseInt(value) > 0));
       applyLineMeasure(resource.key(), lineCount, CoreMetrics.CONDITIONS_BY_LINE_KEY, coveragePerLine,
-        new MeasureOperation() {
-          @Override
-          public void apply(String value, LineCoverage.Builder builder) {
-            builder.setConditions(Integer.parseInt(value));
-          }
-        });
+        (value, builder) -> builder.setConditions(Integer.parseInt(value)));
       applyLineMeasure(resource.key(), lineCount, CoreMetrics.COVERED_CONDITIONS_BY_LINE_KEY, coveragePerLine,
-        new MeasureOperation() {
-          @Override
-          public void apply(String value, LineCoverage.Builder builder) {
-            builder.setUtCoveredConditions(Integer.parseInt(value));
-          }
-        });
-      applyLineMeasure(resource.key(), lineCount, CoreMetrics.IT_COVERED_CONDITIONS_BY_LINE_KEY, coveragePerLine,
-        new MeasureOperation() {
-          @Override
-          public void apply(String value, LineCoverage.Builder builder) {
-            builder.setItCoveredConditions(Integer.parseInt(value));
-          }
-        });
-      applyLineMeasure(resource.key(), lineCount, CoreMetrics.OVERALL_COVERED_CONDITIONS_BY_LINE_KEY, coveragePerLine,
-        new MeasureOperation() {
-          @Override
-          public void apply(String value, LineCoverage.Builder builder) {
-            builder.setOverallCoveredConditions(Integer.parseInt(value));
-          }
-        });
+        (value, builder) -> builder.setCoveredConditions(Integer.parseInt(value)));
       writer.writeComponentCoverage(resource.batchId(), Iterables.transform(coveragePerLine.values(), BuildCoverage.INSTANCE));
     }
   }
index ccc5440ae8663e9c532820f84161144ee0fe7687..0f3c28a14f07e712ce240bfa26935057b7336749 100644 (file)
@@ -83,12 +83,9 @@ public class CoverageMediumTest {
       .start();
 
     InputFile file = result.inputFile("src/sample.xoo");
-    assertThat(result.coverageFor(file, 2).getUtHits()).isTrue();
-    assertThat(result.coverageFor(file, 2).getItHits()).isFalse();
+    assertThat(result.coverageFor(file, 2).getHits()).isTrue();
     assertThat(result.coverageFor(file, 2).getConditions()).isEqualTo(2);
-    assertThat(result.coverageFor(file, 2).getUtCoveredConditions()).isEqualTo(1);
-    assertThat(result.coverageFor(file, 2).getItCoveredConditions()).isEqualTo(0);
-    assertThat(result.coverageFor(file, 2).getOverallCoveredConditions()).isEqualTo(0);
+    assertThat(result.coverageFor(file, 2).getCoveredConditions()).isEqualTo(1);
 
     Map<String, List<org.sonar.scanner.protocol.output.ScannerReport.Measure>> allMeasures = result.allMeasures();
     assertThat(allMeasures.get("com.foo.project:src/sample.xoo")).extracting("metricKey", "intValue.value")
@@ -125,10 +122,10 @@ public class CoverageMediumTest {
       .start();
 
     InputFile file = result.inputFile("src/sample.xoo");
-    assertThat(result.coverageFor(file, 2).getUtHits()).isTrue();
+    assertThat(result.coverageFor(file, 2).getHits()).isTrue();
     assertThat(result.coverageFor(file, 2).getConditions()).isEqualTo(2);
-    assertThat(result.coverageFor(file, 2).getUtCoveredConditions()).isEqualTo(2);
-    assertThat(result.coverageFor(file, 3).getUtHits()).isTrue();
+    assertThat(result.coverageFor(file, 2).getCoveredConditions()).isEqualTo(2);
+    assertThat(result.coverageFor(file, 3).getHits()).isTrue();
 
     Map<String, List<org.sonar.scanner.protocol.output.ScannerReport.Measure>> allMeasures = result.allMeasures();
     assertThat(allMeasures.get("com.foo.project:src/sample.xoo")).extracting("metricKey", "intValue.value")
@@ -199,14 +196,11 @@ public class CoverageMediumTest {
     InputFile file = result.inputFile("src/sample.xoo");
     assertThat(result.coverageFor(file, 1)).isNull();
 
-    assertThat(result.coverageFor(file, 2).getUtHits()).isFalse();
-    assertThat(result.coverageFor(file, 2).getItHits()).isFalse();
+    assertThat(result.coverageFor(file, 2).getHits()).isFalse();
     assertThat(result.coverageFor(file, 2).getConditions()).isEqualTo(0);
-    assertThat(result.coverageFor(file, 2).getUtCoveredConditions()).isEqualTo(0);
-    assertThat(result.coverageFor(file, 2).getItCoveredConditions()).isEqualTo(0);
-    assertThat(result.coverageFor(file, 2).getOverallCoveredConditions()).isEqualTo(0);
+    assertThat(result.coverageFor(file, 2).getCoveredConditions()).isEqualTo(0);
 
-    assertThat(result.coverageFor(file, 3).getUtHits()).isFalse();
+    assertThat(result.coverageFor(file, 3).getHits()).isFalse();
     assertThat(result.coverageFor(file, 4)).isNull();
 
     Map<String, List<org.sonar.scanner.protocol.output.ScannerReport.Measure>> allMeasures = result.allMeasures();
index 6ce6b181fc96984b43185a403f317b786892e90c..95757460e101485a0e5b51bde4d2c02a7efc481b 100644 (file)
@@ -84,17 +84,17 @@ public class CoveragePublisherTest {
     try (CloseableIterator<LineCoverage> it = new ScannerReportReader(outputDir).readComponentCoverage(2)) {
       assertThat(it.next()).isEqualTo(LineCoverage.newBuilder()
         .setLine(2)
-        .setUtHits(true)
+        .setHits(true)
         .build());
       assertThat(it.next()).isEqualTo(LineCoverage.newBuilder()
         .setLine(3)
-        .setUtHits(true)
+        .setHits(true)
         .setConditions(4)
-        .setUtCoveredConditions(2)
+        .setCoveredConditions(2)
         .build());
       assertThat(it.next()).isEqualTo(LineCoverage.newBuilder()
         .setLine(5)
-        .setUtHits(false)
+        .setHits(false)
         .build());
     }
 
index f0ab94c1e2a41bfe67b0f34e180cb0366af99f90..1c4c275242707d2d2f6b73e8770426f15a7b1556 100644 (file)
@@ -217,24 +217,12 @@ message LineCoverage {
   // Number of conditions to cover (if set, the value must be greater than 0)
   int32 conditions = 2;
   // Is the line has been touched by a unit test ? Returning false means that no test has touched this executable line.
-  oneof has_ut_hits {
-    bool ut_hits = 3;
+  oneof has_hits {
+    bool hits = 3;
   }
-  // Is the line has been touched by a integration test ? Returning false means that no test has touched this executable line.
-  oneof has_it_hits {
-    bool it_hits = 4;
-  }
-  // Number of conditions covered by unit tests
-  oneof has_ut_covered_conditions {
-    int32 ut_covered_conditions = 5;
-  }
-  // Number of conditions covered by integration tests
-  oneof has_it_covered_conditions {
-    int32 it_covered_conditions = 6;
-  }
-  // Number of conditions covered by overall tests
-  oneof has_overall_covered_conditions {
-    int32 overall_covered_conditions = 7;
+  // Number of conditions covered by tests
+  oneof has_covered_conditions {
+    int32 covered_conditions = 5;
   }
 }
 
index 98b7c7ac71dc709d6b3632033fb231658847daeb..5a5c5323caff90dcf84cac0aaa8dbcabd009268a 100644 (file)
@@ -277,20 +277,14 @@ public class ScannerReportReaderTest {
       ScannerReport.LineCoverage.newBuilder()
         .setLine(1)
         .setConditions(1)
-        .setUtHits(true)
-        .setItHits(false)
-        .setUtCoveredConditions(1)
-        .setItCoveredConditions(1)
-        .setOverallCoveredConditions(1)
+        .setHits(true)
+        .setCoveredConditions(1)
         .build(),
       ScannerReport.LineCoverage.newBuilder()
         .setLine(2)
         .setConditions(5)
-        .setUtHits(false)
-        .setItHits(false)
-        .setUtCoveredConditions(4)
-        .setItCoveredConditions(5)
-        .setOverallCoveredConditions(5)
+        .setHits(false)
+        .setCoveredConditions(4)
         .build()));
 
     underTest = new ScannerReportReader(dir);
@@ -298,11 +292,8 @@ public class ScannerReportReaderTest {
       ScannerReport.LineCoverage coverage = it.next();
       assertThat(coverage.getLine()).isEqualTo(1);
       assertThat(coverage.getConditions()).isEqualTo(1);
-      assertThat(coverage.getUtHits()).isTrue();
-      assertThat(coverage.getItHits()).isFalse();
-      assertThat(coverage.getUtCoveredConditions()).isEqualTo(1);
-      assertThat(coverage.getItCoveredConditions()).isEqualTo(1);
-      assertThat(coverage.getOverallCoveredConditions()).isEqualTo(1);
+      assertThat(coverage.getHits()).isTrue();
+      assertThat(coverage.getCoveredConditions()).isEqualTo(1);
     }
   }
 
index c55abc01c9b557b60eac11e8ba1a7890b9bd1043..2bd380d55b56626007f58b81f2360759f66b1351 100644 (file)
@@ -272,11 +272,8 @@ public class ScannerReportWriterTest {
       ScannerReport.LineCoverage.newBuilder()
         .setLine(1)
         .setConditions(1)
-        .setUtHits(true)
-        .setItHits(false)
-        .setUtCoveredConditions(1)
-        .setItCoveredConditions(1)
-        .setOverallCoveredConditions(1)
+        .setHits(true)
+        .setCoveredConditions(1)
         .build()));
 
     assertThat(underTest.hasComponentData(FileStructure.Domain.COVERAGES, 1)).isTrue();