]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5884 show ut and it coverage separately
authorStas Vilchik <vilchiks@gmail.com>
Mon, 2 Mar 2015 12:12:11 +0000 (13:12 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 2 Mar 2015 14:20:45 +0000 (15:20 +0100)
server/sonar-web/src/main/hbs/source-viewer/source-viewer.hbs
server/sonar-web/src/main/js/source-viewer/source.js
server/sonar-web/src/main/js/source-viewer/viewer.js
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 0f239f255df387b9f27e092b3537e1b16f21f257..7e57cd0886755b31b3b9dc3a613c58ad7dbc4c25 100644 (file)
           {{/ifSCMChanged2}}
         </td>
 
-        <td class="source-meta source-line-coverage {{#notNull coverageStatus}}source-line-{{coverageStatus}}{{/notNull}}"
-            data-line-number="{{line}}" {{#notNull coverageStatus}}title="{{t 'source_viewer.tooltip' coverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}>
-          <div class="source-line-bar"></div>
-        </td>
+        {{#if ../hasCoverage}}
+          <td class="source-meta source-line-coverage {{#notNull coverageStatus}}source-line-{{coverageStatus}}{{/notNull}}"
+              data-line-number="{{line}}" {{#notNull coverageStatus}}title="{{t 'source_viewer.tooltip.ut' coverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}>
+            <div class="source-line-bar"></div>
+          </td>
+        {{/if}}
+
+        {{#if ../hasITCoverage}}
+          <td class="source-meta source-line-coverage {{#notNull itCoverageStatus}}source-line-{{itCoverageStatus}}{{/notNull}}"
+              data-line-number="{{line}}" {{#notNull itCoverageStatus}}title="{{t 'source_viewer.tooltip.it' itCoverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}>
+            <div class="source-line-bar"></div>
+          </td>
+        {{/if}}
 
         {{#if ../hasDuplications}}
           <td class="source-meta source-line-duplications {{#if duplicated}}source-line-duplicated{{/if}}"
index 3413cbb9ec72f7409462c6b7f42115abc12d3a82..364e33ec2ce4778b421f6c423bb0d27028517863 100644 (file)
@@ -26,6 +26,7 @@ define(function () {
       return {
         hasSource: false,
         hasCoverage: false,
+        hasITCoverage: false,
         hasDuplications: false,
         hasSCM: false,
 
@@ -88,6 +89,18 @@ define(function () {
         });
       }
       this.set({ hasDuplications: hasDuplications });
+    },
+
+    hasCoverage: function (source) {
+      return _.some(source, function (line) {
+        return line.coverageStatus != null;
+      });
+    },
+
+    hasITCoverage: function (source) {
+      return _.some(source, function (line) {
+        return line.itCoverageStatus != null;
+      });
     }
   });
 
index 0afd5d76a5a83b6d1f6cb725e9c42710f974b8f8..a65afb3d98f8d40e71ad42767123d2ed06e95964 100644 (file)
@@ -180,6 +180,20 @@ define([
           return status;
         },
 
+        getItCoverageStatus: function (row) {
+          var status = null;
+          if (row.itLineHits > 0) {
+            status = 'partially-covered';
+          }
+          if (row.itLineHits > 0 && row.itConditions === row.itCoveredConditions) {
+            status = 'covered';
+          }
+          if (row.itLineHits === 0 || row.itCoveredConditions === 0) {
+            status = 'uncovered';
+          }
+          return status;
+        },
+
         requestSource: function () {
           var that = this,
               url = baseUrl + '/api/sources/lines',
@@ -190,12 +204,17 @@ define([
               source.unshift({line: 0});
             }
             source = source.map(function (row) {
-              return _.extend(row, { coverageStatus: that.getCoverageStatus(row) });
+              return _.extend(row, {
+                coverageStatus: that.getCoverageStatus(row),
+                itCoverageStatus: that.getItCoverageStatus(row)
+              });
             });
             var firstLine = _.first(source).line,
                 linesRequested = options.to - options.from + 1;
             that.model.set({
               source: source,
+              hasCoverage: that.model.hasCoverage(source),
+              hasITCoverage: that.model.hasITCoverage(source),
               hasSourceBefore: firstLine > 1,
               hasSourceAfter: data.sources.length === linesRequested
             });
@@ -573,10 +592,15 @@ define([
               source.unshift({line: 0});
             }
             source = source.map(function (row) {
-              return _.extend(row, { coverageStatus: that.getCoverageStatus(row) });
+              return _.extend(row, {
+                coverageStatus: that.getCoverageStatus(row),
+                itCoverageStatus: that.getItCoverageStatus(row)
+              });
             });
             that.model.set({
               source: source,
+              hasCoverage: that.model.hasCoverage(source),
+              hasITCoverage: that.model.hasITCoverage(source),
               hasSourceBefore: (data.sources.length === that.LINES_AROUND) && (_.first(source).line > 0)
             });
             that.addIssuesPerLineMeta(that.issues);
@@ -611,10 +635,15 @@ define([
               that.model.set({ hasSourceBefore: true });
             }
             source = source.map(function (row) {
-              return _.extend(row, { coverageStatus: that.getCoverageStatus(row) });
+              return _.extend(row, {
+                coverageStatus: that.getCoverageStatus(row),
+                itCoverageStatus: that.getItCoverageStatus(row)
+              });
             });
             that.model.set({
               source: source,
+              hasCoverage: that.model.hasCoverage(source),
+              hasITCoverage: that.model.hasITCoverage(source),
               hasSourceAfter: data.sources.length === that.LINES_AROUND
             });
             that.addIssuesPerLineMeta(that.issues);
index daa7a8c7a4aadc99e000181f2261fea9ead4d87b..545f6985999b5c4430bfce96c6af04bfcfc64d0c 100644 (file)
@@ -2900,9 +2900,12 @@ source_viewer.conditions=conditions
 
 source_viewer.tooltip.duplicated_line=This line is duplicated. Click to see duplicated blocks.
 source_viewer.tooltip.duplicated_block=Duplicated block. Click for details.
-source_viewer.tooltip.covered=Fully covered by tests. Click for details.
-source_viewer.tooltip.partially-covered=Partially covered by tests. Click for details.
-source_viewer.tooltip.uncovered=Not covered by tests.
+source_viewer.tooltip.ut.covered=Fully covered by unit tests. Click for details.
+source_viewer.tooltip.ut.partially-covered=Partially covered by unit tests. Click for details.
+source_viewer.tooltip.ut.uncovered=Not covered by unit tests.
+source_viewer.tooltip.it.covered=Fully covered by integration tests. Click for details.
+source_viewer.tooltip.it.partially-covered=Partially covered by integration tests. Click for details.
+source_viewer.tooltip.it.uncovered=Not covered by integration tests.
 source_viewer.tooltip.new_code=New {0}.