Browse Source

SONAR-4093 Display a tooltip that contains number of tests for the current line

tags/3.5
Julien Lancelot 11 years ago
parent
commit
5c9ee1b4ed

+ 1
- 0
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties View File

@@ -1085,6 +1085,7 @@ violations_drilldown.no_violations=No violations
#------------------------------------------------------------------------------

resource_viewer.resource_deleted=This resource has been deleted.
number_of_tests_covering_line=Number of tests covering this line : {0}


#------------------------------------------------------------------------------

+ 2
- 1
sonar-core/src/main/java/org/sonar/core/test/DefaultTestCase.java View File

@@ -101,7 +101,8 @@ public class DefaultTestCase extends BeanVertex implements MutableTestCase {
}

public void covers(Testable testable, List<Integer> lines) {
beanGraph().getUnderlyingGraph().addEdge(null, element(), ((BeanVertex) testable).element(), "covers").setProperty("lines", lines);
BeanVertex testableVertex = ((BeanVertex) testable);
beanGraph().getUnderlyingGraph().addEdge(null, element(), testableVertex.element(), "covers").setProperty("lines", lines);
}

public TestPlan testPlan() {

+ 10
- 0
sonar-core/src/main/java/org/sonar/core/test/DefaultTestable.java View File

@@ -54,6 +54,16 @@ public class DefaultTestable extends BeanVertex implements MutableTestable {
return testCases;
}

public int countTestCasesOfLine(int line) {
int number = 0;
for (Edge edge : getCovers()) {
if (Iterables.contains(testedLines(edge), Long.valueOf(line))) {
number++;
}
}
return number;
}

public Collection<TestCase> testCasesOfLine(int line) {
ImmutableList.Builder<TestCase> cases = ImmutableList.builder();
for (Edge edge : getCovers()) {

+ 2
- 0
sonar-plugin-api/src/main/java/org/sonar/api/test/Testable.java View File

@@ -28,6 +28,8 @@ public interface Testable extends Perspective {

Collection<TestCase> testCases();

int countTestCasesOfLine(int line);

Collection<TestCase> testCasesOfLine(int line);

SortedSet<Long> testedLines();

+ 2
- 1
sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb View File

@@ -195,7 +195,8 @@ class ResourceController < ApplicationController
@hits_by_line.each_pair do |line_id, hits|
line = @lines[line_id-1]
if line
line.covered_lines = testable.testCasesOfLine(line_id).size if testable && testable.testCasesOfLine(line_id).size > 0
line.covered_lines = 0
line.covered_lines = testable.countTestCasesOfLine(line_id) if testable
line.hits = hits.to_i
line.conditions = @conditions_by_line[line_id].to_i
line.covered_conditions = @covered_conditions_by_line[line_id].to_i

+ 1
- 1
sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb View File

@@ -99,7 +99,7 @@

<% if @display_coverage %>
<% if line.highlighted? %>
<td class="ind <%= hits_status -%>"><%= line.covered_lines if line.covered_lines -%></td>
<td class="ind <%= hits_status -%>" title="<%= message("number_of_tests_covering_line", {:params => line.covered_lines.to_s}) if line.covered_lines > 0 -%>"><%= line.covered_lines if line.covered_lines > 0 -%></td>
<td class="ind <%= conditions_status -%>">
<% if line.deprecated_conditions_label -%>
<%= line.deprecated_conditions_label -%>

Loading…
Cancel
Save