aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-11-02 11:28:12 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2011-11-02 11:28:50 +0100
commit13ff8a717d1837a2a430aec0a2e1cb115da0afeb (patch)
tree0b4ee8c7708763979e37a619040fc708dc957c7b
parent41fdffbc9ce51080a55e33fcee1a2f5b7e1573cc (diff)
downloadsonarqube-13ff8a717d1837a2a430aec0a2e1cb115da0afeb.tar.gz
sonarqube-13ff8a717d1837a2a430aec0a2e1cb115da0afeb.zip
SONAR-2963 Add the widget "Integration Test Coverage"
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java3
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoverageWidget.java (renamed from plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CodeCoverageWidget.java)8
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ItCoverageWidget.java (renamed from plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageWidget.java)19
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb (renamed from plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb)0
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb73
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java (renamed from plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensor.java)6
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java5
-rw-r--r--plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/widget.html.erb32
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java (renamed from plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensorTest.java)5
-rw-r--r--plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageWidgetTest.java38
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties9
11 files changed, 103 insertions, 95 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 00ea4547077..9cf9ab27cc3 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -232,7 +232,8 @@ public class CorePlugin extends SonarPlugin {
// widgets
extensions.add(AlertsWidget.class);
- extensions.add(CodeCoverageWidget.class);
+ extensions.add(CoverageWidget.class);
+ extensions.add(ItCoverageWidget.class);
extensions.add(CommentsDuplicationsWidget.class);
extensions.add(DescriptionWidget.class);
extensions.add(ComplexityWidget.class);
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CodeCoverageWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoverageWidget.java
index 9be40a0e5cf..4758c8ff5bd 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CodeCoverageWidget.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/CoverageWidget.java
@@ -21,10 +21,12 @@ package org.sonar.plugins.core.widgets;
import org.sonar.api.web.AbstractRubyTemplate;
import org.sonar.api.web.RubyRailsWidget;
+import org.sonar.api.web.UserRole;
import org.sonar.api.web.WidgetCategory;
-@WidgetCategory({ "Tests" })
-public class CodeCoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget {
+@WidgetCategory("Tests")
+@UserRole(UserRole.USER)
+public class CoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget {
public String getId() {
return "code_coverage";
@@ -36,6 +38,6 @@ public class CodeCoverageWidget extends AbstractRubyTemplate implements RubyRail
@Override
protected String getTemplatePath() {
- return "/org/sonar/plugins/core/widgets/code_coverage.html.erb";
+ return "/org/sonar/plugins/core/widgets/coverage.html.erb";
}
} \ No newline at end of file
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ItCoverageWidget.java
index 65ef6ef25bb..7008ebbd7dd 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageWidget.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/ItCoverageWidget.java
@@ -17,28 +17,27 @@
* License along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
-package org.sonar.plugins.jacoco.itcoverage;
+package org.sonar.plugins.core.widgets;
import org.sonar.api.web.AbstractRubyTemplate;
-import org.sonar.api.web.NavigationSection;
import org.sonar.api.web.RubyRailsWidget;
import org.sonar.api.web.UserRole;
+import org.sonar.api.web.WidgetCategory;
-@NavigationSection(NavigationSection.RESOURCE)
+@WidgetCategory({ "Tests" })
@UserRole(UserRole.USER)
public class ItCoverageWidget extends AbstractRubyTemplate implements RubyRailsWidget {
- @Override
- protected String getTemplatePath() {
- return "/org/sonar/plugins/jacoco/itcoverage/widget.html.erb";
- }
-
public String getId() {
return "it-coverage";
}
public String getTitle() {
- return "IT Coverage widget";
+ return "Coverage by Integration Tests";
}
-}
+ @Override
+ protected String getTemplatePath() {
+ return "/org/sonar/plugins/core/widgets/it_coverage.html.erb";
+ }
+} \ No newline at end of file
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb
index d63b82f1b41..d63b82f1b41 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/code_coverage.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/coverage.html.erb
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb
new file mode 100644
index 00000000000..67ea9e9b9bc
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/it_coverage.html.erb
@@ -0,0 +1,73 @@
+<%
+ coverage_measure=measure('it_coverage')
+ if coverage_measure
+%>
+<table width="100%">
+ <tr>
+ <td nowrap>
+ <div class="dashbox">
+ <p class="title"><%= message('widget.it_coverage.name') -%></p>
+ <p>
+ <span class="big"><%= format_measure(coverage_measure, :suffix => '', :url => url_for_drilldown('it_coverage'), :default => '-') %></span>
+ <%= dashboard_configuration.selected_period? ? format_variation(coverage_measure) : trend_icon(coverage_measure) -%>
+ </p>
+ <% it_line_coverage=measure('it_line_coverage')
+ if it_line_coverage %>
+ <p>
+ <%= format_measure(it_line_coverage, :suffix => message('widget.it_coverage.line_coverage.suffix'), :url => url_for_drilldown('it_uncovered_lines', :highlight => 'it_line_coverage')) %>
+ <%= dashboard_configuration.selected_period? ? format_variation(it_line_coverage) : trend_icon(it_line_coverage) -%>
+ </p>
+ <% end %>
+ <% it_branch_coverage=measure('it_branch_coverage')
+ if it_branch_coverage %>
+ <p>
+ <%= format_measure(it_branch_coverage, :suffix => message('widget.it_coverage.branch_coverage.suffix'), :url => url_for_drilldown('it_uncovered_conditions', :highlight => 'it_branch_coverage')) %>
+ <%= dashboard_configuration.selected_period? ? format_variation(it_branch_coverage) : trend_icon(it_branch_coverage) -%>
+ </p>
+ <% end %>
+
+ <%
+ if dashboard_configuration.selected_period?
+ new_lines_to_cover_measure=measure('new_it_lines_to_cover')
+ if new_lines_to_cover_measure
+ new_lines=new_lines_to_cover_measure.variation(dashboard_configuration.period_index)
+ if new_lines
+ new_coverage=measure('new_it_coverage')
+ new_line_coverage=measure('new_it_line_coverage')
+ new_branch_coverage=measure('new_it_branch_coverage')
+ %> <br/>
+ <h3><%= message('widget.it_coverage.on_new_code') -%>: </h3>
+ <% if new_lines.to_i==0 %>
+ <p><%= message('widget.it_coverage.no_new_lines_to_cover') -%></p>
+ <% else %>
+ <% if new_coverage %>
+ <p>
+ <span class="big"><a href="<%= url_for_drilldown('new_it_coverage', :period => dashboard_configuration.period_index) -%>"><%= new_coverage.format_numeric_value(variation_value(new_coverage))||'-' -%></a></span>
+ </p>
+ <% end %>
+ <p>
+ <a href="<%= url_for_drilldown('new_it_lines_to_cover', :period => dashboard_configuration.period_index) -%>"><%= new_lines.to_i -%><%= message('widget.it_coverage.lines_to_cover.suffix') -%></a>
+ </p>
+ <% if new_line_coverage %>
+ <p>
+ <a href="<%= url_for_drilldown('new_it_uncovered_lines', :highlight => 'new_it_line_coverage', :period => dashboard_configuration.period_index) -%>"><%= new_line_coverage.format_numeric_value(variation_value(new_line_coverage))||'-' -%><%= message('widget.it_coverage.line_coverage.suffix') -%></a>
+ </p>
+ <% end %>
+ <% if new_branch_coverage %>
+ <p>
+ <a href="<%= url_for_drilldown('new_it_uncovered_conditions', :highlight => 'new_it_branch_coverage', :period => dashboard_configuration.period_index) -%>"><%= new_branch_coverage.format_numeric_value(variation_value(new_branch_coverage))||'-' -%><%= message('widget.it_coverage.branch_coverage.suffix') -%></a>
+ </p>
+ <%
+ end
+ end
+ end
+ end
+ end
+ %>
+ </div>
+ </td>
+</tr>
+</table>
+<% end %>
+
+
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensor.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java
index 8d1d54604bd..89a1c83ddf0 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensor.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoItSensor.java
@@ -17,7 +17,7 @@
* License along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
-package org.sonar.plugins.jacoco.itcoverage;
+package org.sonar.plugins.jacoco;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.batch.Sensor;
@@ -26,15 +26,13 @@ import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Measure;
import org.sonar.api.resources.JavaFile;
import org.sonar.api.resources.Project;
-import org.sonar.plugins.jacoco.AbstractAnalyzer;
-import org.sonar.plugins.jacoco.JacocoConfiguration;
import java.util.Collection;
/**
* Note that this class can't extend {@link org.sonar.api.batch.AbstractCoverageExtension}, because in this case this extension will be
* disabled under Sonar 2.3, if JaCoCo is not defined as the default code coverage plugin.
- *
+ *
* @author Evgeny Mandrikov
*/
public class JaCoCoItSensor implements Sensor {
diff --git a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
index aee588e9d47..447f746a826 100644
--- a/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
+++ b/plugins/sonar-jacoco-plugin/src/main/java/org/sonar/plugins/jacoco/JaCoCoPlugin.java
@@ -22,7 +22,6 @@ package org.sonar.plugins.jacoco;
import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.SonarPlugin;
-import org.sonar.plugins.jacoco.itcoverage.*;
import java.util.Arrays;
import java.util.List;
@@ -99,9 +98,7 @@ public class JaCoCoPlugin extends SonarPlugin {
JaCoCoMavenPluginHandler.class,
// Unit tests
JaCoCoSensor.class,
-
// Integration tests
- JaCoCoItSensor.class,
- ItCoverageWidget.class);
+ JaCoCoItSensor.class);
}
}
diff --git a/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/widget.html.erb b/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/widget.html.erb
deleted file mode 100644
index 00f91c0bb2b..00000000000
--- a/plugins/sonar-jacoco-plugin/src/main/resources/org/sonar/plugins/jacoco/itcoverage/widget.html.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-<%
- it_coverage_measure=measure('it_coverage')
- if it_coverage_measure %>
- <table width="100%">
- <tr>
- <td valign="top" width="100%">
- <div class="dashbox">
- <p class="title">IT Code coverage</p>
-
- <p>
- <span class="big"><%= format_measure(it_coverage_measure, :suffix => '', :url => url_for_drilldown('it_coverage'), :default => '-') %></span>
- <%= dashboard_configuration.selected_period? ? format_variation(it_coverage_measure) : trend_icon(it_coverage_measure) -%>
- </p>
- <% it_line_coverage=measure('it_line_coverage')
- if it_line_coverage %>
- <p>
- <%= format_measure(it_line_coverage, :suffix => ' IT line coverage', :url => url_for_drilldown('it_uncovered_lines', :highlight => 'it_line_coverage')) %>
- <%= dashboard_configuration.selected_period? ? format_variation(it_line_coverage) : trend_icon(it_line_coverage) -%>
- </p>
- <% end %>
- <% it_branch_coverage=measure('it_branch_coverage')
- if it_branch_coverage %>
- <p>
- <%= format_measure(it_branch_coverage, :suffix => ' IT branch coverage', :url => url_for_drilldown('it_uncovered_conditions', :highlight => 'it_branch_coverage')) %>
- <%= dashboard_configuration.selected_period? ? format_variation(it_branch_coverage) : trend_icon(it_branch_coverage) -%>
- </p>
- <% end %>
- </div>
- </td>
- </tr>
- </table>
-<% end %>
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensorTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java
index 524e9070908..2e2da4db9a6 100644
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/JaCoCoItSensorTest.java
+++ b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/JaCoCoItSensorTest.java
@@ -17,7 +17,7 @@
* License along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
-package org.sonar.plugins.jacoco.itcoverage;
+package org.sonar.plugins.jacoco;
import org.junit.Before;
import org.junit.Test;
@@ -30,7 +30,6 @@ import org.sonar.api.resources.Project.AnalysisType;
import org.sonar.api.resources.ProjectFileSystem;
import org.sonar.api.resources.Resource;
import org.sonar.api.test.IsMeasure;
-import org.sonar.plugins.jacoco.JacocoConfiguration;
import java.io.File;
@@ -95,7 +94,7 @@ public class JaCoCoItSensorTest {
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_LINES_TO_COVER, 7.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_LINES, 3.0)));
verify(context).saveMeasure(eq(resource),
- argThat(new IsMeasure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
+ argThat(new IsMeasure(CoreMetrics.IT_COVERAGE_LINE_HITS_DATA, "6=1;7=1;8=1;11=1;15=0;16=0;18=0")));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_TO_COVER, 2.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_UNCOVERED_CONDITIONS, 2.0)));
verify(context).saveMeasure(eq(resource), argThat(new IsMeasure(CoreMetrics.IT_CONDITIONS_BY_LINE, "15=2")));
diff --git a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageWidgetTest.java b/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageWidgetTest.java
deleted file mode 100644
index bb5870e7733..00000000000
--- a/plugins/sonar-jacoco-plugin/src/test/java/org/sonar/plugins/jacoco/itcoverage/ItCoverageWidgetTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.jacoco.itcoverage;
-
-import org.junit.Test;
-
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertThat;
-
-/**
- * @author Evgeny Mandrikov
- */
-public class ItCoverageWidgetTest {
-
- @Test
- public void testGetTemplatePath() {
- String path = new ItCoverageWidget().getTemplatePath();
- assertThat(getClass().getResource(path), notNullValue());
- }
-
-}
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
index 0a60f2e9a89..7f58fb1ba24 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -464,6 +464,15 @@ widget.code_coverage.errors.suffix=\ errors
widget.code_coverage.tests.suffix=\ tests
widget.code_coverage.skipped.suffix=\ skipped
+widget.it_coverage.name=Coverage by Integration Tests
+widget.it_coverage.description=Reports code coverage by integration tests
+widget.it_coverage.line_coverage.suffix=\ line coverage
+widget.it_coverage.branch_coverage.suffix=\ branch coverage
+widget.it_coverage.lines_to_cover.suffix=\ lines to cover
+widget.it_coverage.on_new_code=On new code
+widget.it_coverage.no_new_lines_to_cover=No new lines to cover
+
+
widget.comments_duplications.name=Comments & Duplications
widget.comments_duplications.description=Reports on copy/paste and documentation
widget.comments_duplications.comments=Comments