@@ -59,8 +59,8 @@ | |||
test_case[:name] = test.name() | |||
test_case[:status] = test.status() | |||
test_case[:time] = test.durationInMs() | |||
has_covered_lines = test.hasCoveredBlocks() | |||
test_case[:covered_lines] = test.countCoveredBlocks() if test.hasCoveredBlocks() | |||
has_covered_lines = test.hasCoveredLines() | |||
test_case[:covered_lines] = test.countCoveredLines() if has_covered_lines | |||
if test.status() != 'ok' | |||
test_case[:message] = '' | |||
test_case[:message] = test.message() if test.message() | |||
@@ -70,6 +70,7 @@ | |||
end | |||
end | |||
end | |||
test_cases = test_cases.sort_by {|test_case| test_case[:name]} | |||
%> | |||
<% if !test_cases.empty? %> | |||
<table class="data width100 tests_viewer" id="test_data"> |
@@ -116,20 +116,20 @@ public class DefaultTestCase extends BeanVertex implements MutableTestCase { | |||
return beanGraph().wrap(plan, DefaultTestPlan.class); | |||
} | |||
public boolean hasCoveredBlocks(){ | |||
public boolean hasCoveredLines(){ | |||
return Iterables.size(element().getEdges(Direction.OUT, "covers")) > 0; | |||
} | |||
public int countCoveredBlocks() { | |||
public int countCoveredLines() { | |||
int coveredBlocks = 0; | |||
for (Edge edge : element().getEdges(Direction.OUT, "covers")){ | |||
List<String> lines = (List<String>) edge.getProperty("lines"); | |||
List<Integer> lines = (List<Integer>) edge.getProperty("lines"); | |||
coveredBlocks = coveredBlocks + lines.size(); | |||
} | |||
return coveredBlocks; | |||
} | |||
public Collection<CoveredTestable> coveredBlocks() { | |||
public Collection<CoveredTestable> coveredTestable() { | |||
return null; | |||
} | |||
} |
@@ -20,6 +20,7 @@ | |||
package org.sonar.core.test; | |||
import com.tinkerpop.blueprints.Direction; | |||
import com.tinkerpop.blueprints.Edge; | |||
import com.tinkerpop.blueprints.Vertex; | |||
import org.sonar.api.component.Component; | |||
import org.sonar.api.test.MutableTestable; | |||
@@ -31,6 +32,8 @@ import org.sonar.core.graph.GraphUtil; | |||
import java.util.List; | |||
import java.util.SortedSet; | |||
import static com.google.common.collect.Sets.newTreeSet; | |||
public class DefaultTestable extends BeanVertex implements MutableTestable { | |||
public Component component() { | |||
@@ -47,8 +50,12 @@ public class DefaultTestable extends BeanVertex implements MutableTestable { | |||
} | |||
public SortedSet<Integer> coveredLines() { | |||
return null; | |||
SortedSet<Integer> coveredLines = newTreeSet(); | |||
for (Edge edge : element().getEdges(Direction.IN, "covers")){ | |||
List<Integer> lines = (List<Integer>) edge.getProperty("lines"); | |||
coveredLines.addAll(lines); | |||
} | |||
return coveredLines; | |||
} | |||
} | |||
} |
@@ -52,9 +52,9 @@ public interface TestCase { | |||
TestPlan testPlan(); | |||
boolean hasCoveredBlocks(); | |||
boolean hasCoveredLines(); | |||
int countCoveredBlocks(); | |||
int countCoveredLines(); | |||
Collection<CoveredTestable> coveredBlocks(); | |||
Collection<CoveredTestable> coveredTestable(); | |||
} |
@@ -25,8 +25,11 @@ import java.util.List; | |||
import java.util.SortedSet; | |||
public interface Testable extends Perspective { | |||
List<TestCase> coveringTestCases(); | |||
List<TestCase> testCasesCoveringLine(int line); | |||
SortedSet<Integer> coveredLines(); | |||
} |