aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.report.test/src
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2011-01-08 18:15:30 +0000
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2011-01-08 18:15:30 +0000
commit5f6c308ae550ddfe2c139c47e39c8cbab6e7d535 (patch)
tree0850e8b83ab66f4a2660fc5860ab1099c2155773 /org.jacoco.report.test/src
parentb075623319d8b01b02b75a530dfa6d3b79392d1e (diff)
downloadjacoco-5f6c308ae550ddfe2c139c47e39c8cbab6e7d535.tar.gz
Trac #130: Count instructions per line.
Diffstat (limited to 'org.jacoco.report.test/src')
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/MultiFormatterTest.java2
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/ReportStructureTestDriver.java2
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/csv/CSVFormatterTest.java2
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/html/NodePageTest.java4
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/html/SourceFilePageTest.java2
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/html/SourceHighlighterTest.java87
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/internal/html/table/BarColumnTest.java2
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/internal/html/table/CounterColumnTest.java2
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/internal/html/table/LabelColumnTest.java9
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/internal/html/table/PercentageColumnTest.java2
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/internal/html/table/TableTest.java5
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/xml/XMLFormatterTest.java11
-rw-r--r--org.jacoco.report.test/src/org/jacoco/report/xml/XMLReportNodeHandlerTest.java64
13 files changed, 74 insertions, 120 deletions
diff --git a/org.jacoco.report.test/src/org/jacoco/report/MultiFormatterTest.java b/org.jacoco.report.test/src/org/jacoco/report/MultiFormatterTest.java
index e42bee6b..fb6b3e1f 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/MultiFormatterTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/MultiFormatterTest.java
@@ -88,7 +88,7 @@ public class MultiFormatterTest {
}
private CoverageNodeImpl createNode(String name) {
- return new CoverageNodeImpl(ElementType.GROUP, name, false);
+ return new CoverageNodeImpl(ElementType.GROUP, name);
}
private static final String MOCK_REPORT = "Session[b1[p1[], p2[]], b2[]]";
diff --git a/org.jacoco.report.test/src/org/jacoco/report/ReportStructureTestDriver.java b/org.jacoco.report.test/src/org/jacoco/report/ReportStructureTestDriver.java
index db97edfc..671d2216 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/ReportStructureTestDriver.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/ReportStructureTestDriver.java
@@ -67,7 +67,7 @@ public class ReportStructureTestDriver {
Collections.singleton(packageCoverage));
private final CoverageNodeImpl groupCoverage = new CoverageNodeImpl(
- ElementType.GROUP, "group", false);
+ ElementType.GROUP, "group");
public ReportStructureTestDriver() {
classCoverage.setSourceFileName("FooClass.java");
diff --git a/org.jacoco.report.test/src/org/jacoco/report/csv/CSVFormatterTest.java b/org.jacoco.report.test/src/org/jacoco/report/csv/CSVFormatterTest.java
index 154a9733..5dbc297f 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/csv/CSVFormatterTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/csv/CSVFormatterTest.java
@@ -82,7 +82,7 @@ public class CSVFormatterTest {
@Test
public void testStructureWithNestedGroups() throws IOException {
final ICoverageNode root = new CoverageNodeImpl(ElementType.GROUP,
- "root", false);
+ "root");
final List<SessionInfo> sessions = Collections.emptyList();
final Collection<ExecutionData> data = Collections.emptyList();
final IReportVisitor child = formatter.createReportVisitor(root,
diff --git a/org.jacoco.report.test/src/org/jacoco/report/html/NodePageTest.java b/org.jacoco.report.test/src/org/jacoco/report/html/NodePageTest.java
index 5b6a868c..3d5fc210 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/html/NodePageTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/html/NodePageTest.java
@@ -111,7 +111,7 @@ public class NodePageTest {
return Locale.ENGLISH;
}
};
- node = new CoverageNodeImpl(ElementType.GROUP, "Test", false);
+ node = new CoverageNodeImpl(ElementType.GROUP, "Test");
page = new TestNodePage(node);
}
@@ -122,7 +122,7 @@ public class NodePageTest {
@Test
public void testGetNode() throws IOException {
- node.increment(new CoverageNodeImpl(ElementType.GROUP, "Foo", false) {
+ node.increment(new CoverageNodeImpl(ElementType.GROUP, "Foo") {
{
branchCounter = CounterImpl.getInstance(15, 8);
}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/html/SourceFilePageTest.java b/org.jacoco.report.test/src/org/jacoco/report/html/SourceFilePageTest.java
index 017cdf9d..7fac6e6b 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/html/SourceFilePageTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/html/SourceFilePageTest.java
@@ -106,7 +106,7 @@ public class SourceFilePageTest {
"SourceFilePageTest.java", "org/jacoco/report/html");
final SourceFilePage page = new SourceFilePage(node, null, root,
context);
- page.visitChild(new CoverageNodeImpl(ElementType.CLASS, "Foo", false));
+ page.visitChild(new CoverageNodeImpl(ElementType.CLASS, "Foo"));
}
@Test
diff --git a/org.jacoco.report.test/src/org/jacoco/report/html/SourceHighlighterTest.java b/org.jacoco.report.test/src/org/jacoco/report/html/SourceHighlighterTest.java
index d9f0aa8d..bb2047bf 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/html/SourceHighlighterTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/html/SourceHighlighterTest.java
@@ -17,7 +17,9 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.util.Locale;
-import org.jacoco.core.analysis.LinesImpl;
+import org.jacoco.core.analysis.CounterImpl;
+import org.jacoco.core.analysis.ICoverageNode.ElementType;
+import org.jacoco.core.analysis.SourceNodeImpl;
import org.jacoco.report.internal.html.resources.Styles;
import org.junit.Before;
import org.junit.Test;
@@ -41,12 +43,12 @@ public class SourceHighlighterTest {
private SourceHighlighter sourceHighlighter;
- private LinesImpl lines;
+ private SourceNodeImpl source;
@Before
public void setup() throws Exception {
htmlSupport = new HTMLSupport();
- lines = new LinesImpl();
+ source = new SourceNodeImpl(ElementType.SOURCEFILE, "Foo.java");
buffer = new StringWriter();
html = new HTMLDocument(buffer, "UTF-8");
html.head().title();
@@ -57,7 +59,7 @@ public class SourceHighlighterTest {
@Test
public void testLineNumbering() throws Exception {
final String src = "A\nB\nC\nD";
- sourceHighlighter.render(parent, lines, new StringReader(src));
+ sourceHighlighter.render(parent, source, new StringReader(src));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("\u00A0\u00A0\u00A0\u00A01",
@@ -73,7 +75,7 @@ public class SourceHighlighterTest {
@Test
public void testLineIds() throws Exception {
final String src = "A\nB\nC\nD";
- sourceHighlighter.render(parent, lines, new StringReader(src));
+ sourceHighlighter.render(parent, source, new StringReader(src));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("L1", htmlSupport.findStr(doc, "//pre/span[1]/@id"));
@@ -85,7 +87,7 @@ public class SourceHighlighterTest {
@Test
public void testDefaultTabWidth() throws Exception {
final String src = "\tA";
- sourceHighlighter.render(parent, lines, new StringReader(src));
+ sourceHighlighter.render(parent, source, new StringReader(src));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals(" A\n", htmlSupport.findStr(doc, "//pre/text()"));
@@ -95,7 +97,7 @@ public class SourceHighlighterTest {
public void testSetTabWidth() throws Exception {
final String src = "\tA";
sourceHighlighter.setTabWidth(3);
- sourceHighlighter.render(parent, lines, new StringReader(src));
+ sourceHighlighter.render(parent, source, new StringReader(src));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals(" A\n", htmlSupport.findStr(doc, "//pre/text()"));
@@ -103,7 +105,7 @@ public class SourceHighlighterTest {
@Test
public void testDefaultLanguage() throws Exception {
- sourceHighlighter.render(parent, lines, new StringReader(""));
+ sourceHighlighter.render(parent, source, new StringReader(""));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("source lang-java",
@@ -113,7 +115,7 @@ public class SourceHighlighterTest {
@Test
public void testSetLanguage() throws Exception {
sourceHighlighter.setLanguage("scala");
- sourceHighlighter.render(parent, lines, new StringReader(""));
+ sourceHighlighter.render(parent, source, new StringReader(""));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("source lang-scala",
@@ -123,11 +125,11 @@ public class SourceHighlighterTest {
@Test
public void testHighlighting() throws Exception {
final String src = "A\nB\nC\nD";
- lines.incrementInsn(1, false);
- lines.incrementInsn(2, false);
- lines.incrementInsn(2, true);
- lines.incrementInsn(3, true);
- sourceHighlighter.render(parent, lines, new StringReader(src));
+ source.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 1);
+ source.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 2);
+ source.increment(CounterImpl.COUNTER_0_1, CounterImpl.COUNTER_0_0, 2);
+ source.increment(CounterImpl.COUNTER_0_1, CounterImpl.COUNTER_0_0, 3);
+ sourceHighlighter.render(parent, source, new StringReader(src));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals(Styles.NOT_COVERED,
@@ -142,27 +144,17 @@ public class SourceHighlighterTest {
@Test
public void testHighlightNone() throws Exception {
- sourceHighlighter.highlight(parent, lines, 1);
+ sourceHighlighter.highlight(parent, source.getLine(1));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("", htmlSupport.findStr(doc, "//pre"));
}
@Test
- public void testHighlightFC() throws Exception {
- lines.incrementInsn(1, true);
- sourceHighlighter.highlight(parent.pre(null), lines, 1);
- html.close();
- final Document doc = htmlSupport.parse(buffer.toString());
- assertEquals("fc", htmlSupport.findStr(doc, "//pre/span/@class"));
- assertEquals("", htmlSupport.findStr(doc, "//pre/span/@title"));
- }
-
- @Test
- public void testHighlightFC_branchesFC() throws Exception {
- lines.incrementInsn(1, true);
- lines.incrementBranches(0, 5, 1);
- sourceHighlighter.highlight(parent.pre(null), lines, 1);
+ public void testHighlightBranchesFC() throws Exception {
+ source.increment(CounterImpl.COUNTER_0_1,
+ CounterImpl.getInstance(0, 5), 1);
+ sourceHighlighter.highlight(parent.pre(null), source.getLine(1));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("fc bfc", htmlSupport.findStr(doc, "//pre/span/@class"));
@@ -171,10 +163,10 @@ public class SourceHighlighterTest {
}
@Test
- public void testHighlightFC_branchesPC() throws Exception {
- lines.incrementInsn(1, true);
- lines.incrementBranches(2, 3, 1);
- sourceHighlighter.highlight(parent.pre(null), lines, 1);
+ public void testHighlightBranchesPC() throws Exception {
+ source.increment(CounterImpl.COUNTER_0_1,
+ CounterImpl.getInstance(2, 3), 1);
+ sourceHighlighter.highlight(parent.pre(null), source.getLine(1));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("pc bpc", htmlSupport.findStr(doc, "//pre/span/@class"));
@@ -183,10 +175,10 @@ public class SourceHighlighterTest {
}
@Test
- public void testHighlightFC_branchesNC() throws Exception {
- lines.incrementInsn(1, true);
- lines.incrementBranches(5, 0, 1);
- sourceHighlighter.highlight(parent.pre(null), lines, 1);
+ public void testHighlightBranchesNC() throws Exception {
+ source.increment(CounterImpl.COUNTER_0_1,
+ CounterImpl.getInstance(5, 0), 1);
+ sourceHighlighter.highlight(parent.pre(null), source.getLine(1));
html.close();
final Document doc = htmlSupport.parse(buffer.toString());
assertEquals("pc bnc", htmlSupport.findStr(doc, "//pre/span/@class"));
@@ -194,25 +186,4 @@ public class SourceHighlighterTest {
htmlSupport.findStr(doc, "//pre/span/@title"));
}
- @Test
- public void testHighlightPC() throws Exception {
- lines.incrementInsn(1, false);
- lines.incrementInsn(1, true);
- sourceHighlighter.highlight(parent.pre(null), lines, 1);
- html.close();
- final Document doc = htmlSupport.parse(buffer.toString());
- assertEquals("pc", htmlSupport.findStr(doc, "//pre/span/@class"));
- assertEquals("", htmlSupport.findStr(doc, "//pre/span/@title"));
- }
-
- @Test
- public void testHighlightNC() throws Exception {
- lines.incrementInsn(1, false);
- sourceHighlighter.highlight(parent.pre(null), lines, 1);
- html.close();
- final Document doc = htmlSupport.parse(buffer.toString());
- assertEquals("nc", htmlSupport.findStr(doc, "//pre/span/@class"));
- assertEquals("", htmlSupport.findStr(doc, "//pre/span/@title"));
- }
-
}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/BarColumnTest.java b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/BarColumnTest.java
index 12720457..f67b9861 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/BarColumnTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/BarColumnTest.java
@@ -215,7 +215,7 @@ public class BarColumnTest {
}
private CoverageNodeImpl createNode(final int missed, final int covered) {
- return new CoverageNodeImpl(ElementType.GROUP, "Foo", false) {
+ return new CoverageNodeImpl(ElementType.GROUP, "Foo") {
{
this.lineCounter = CounterImpl.getInstance(missed, covered);
}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/CounterColumnTest.java b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/CounterColumnTest.java
index 739f7341..95565d70 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/CounterColumnTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/CounterColumnTest.java
@@ -219,7 +219,7 @@ public class CounterColumnTest {
}
private CoverageNodeImpl createNode(final int missed, final int covered) {
- return new CoverageNodeImpl(ElementType.GROUP, "Foo", false) {
+ return new CoverageNodeImpl(ElementType.GROUP, "Foo") {
{
this.lineCounter = CounterImpl.getInstance(missed, covered);
}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/LabelColumnTest.java b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/LabelColumnTest.java
index 30ad843b..56a55956 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/LabelColumnTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/LabelColumnTest.java
@@ -23,9 +23,6 @@ import org.jacoco.report.html.HTMLDocument;
import org.jacoco.report.html.HTMLElement;
import org.jacoco.report.html.HTMLSupport;
import org.jacoco.report.internal.html.resources.Resources;
-import org.jacoco.report.internal.html.table.IColumnRenderer;
-import org.jacoco.report.internal.html.table.ITableItem;
-import org.jacoco.report.internal.html.table.LabelColumn;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -78,8 +75,7 @@ public class LabelColumnTest {
@Test
public void testFooter() throws Exception {
- column.footer(td,
- new CoverageNodeImpl(ElementType.GROUP, "Foo", false),
+ column.footer(td, new CoverageNodeImpl(ElementType.GROUP, "Foo"),
resources, root);
doc.close();
final Document doc = support.parse(output.getFile("Test.html"));
@@ -129,8 +125,7 @@ public class LabelColumnTest {
}
private ITableItem createItem(final String name, final String link) {
- final ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP,
- name, false);
+ final ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP, name);
return new ITableItem() {
public String getLinkLabel() {
return name;
diff --git a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/PercentageColumnTest.java b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/PercentageColumnTest.java
index 086eebe3..1eccfd80 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/PercentageColumnTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/PercentageColumnTest.java
@@ -161,7 +161,7 @@ public class PercentageColumnTest {
}
private CoverageNodeImpl createNode(final int missed, final int covered) {
- return new CoverageNodeImpl(ElementType.GROUP, "Foo", false) {
+ return new CoverageNodeImpl(ElementType.GROUP, "Foo") {
{
this.lineCounter = CounterImpl.getInstance(missed, covered);
}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/TableTest.java b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/TableTest.java
index 47f0b2ad..f404007b 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/TableTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/internal/html/table/TableTest.java
@@ -224,8 +224,7 @@ public class TableTest {
}
private ITableItem createItem(final String name, final int count) {
- final ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP,
- name, false) {
+ final ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP, name) {
{
this.classCounter = CounterImpl.getInstance(count, 0);
}
@@ -250,7 +249,7 @@ public class TableTest {
}
private ICoverageNode createTotal(final String name, final int count) {
- return new CoverageNodeImpl(ElementType.GROUP, name, false) {
+ return new CoverageNodeImpl(ElementType.GROUP, name) {
{
this.classCounter = CounterImpl.getInstance(count, 0);
}
diff --git a/org.jacoco.report.test/src/org/jacoco/report/xml/XMLFormatterTest.java b/org.jacoco.report.test/src/org/jacoco/report/xml/XMLFormatterTest.java
index ae243713..c4023376 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/xml/XMLFormatterTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/xml/XMLFormatterTest.java
@@ -72,8 +72,7 @@ public class XMLFormatterTest {
infos.add(new SessionInfo("session-1", 12345, 67890));
infos.add(new SessionInfo("session-2", 1, 2));
infos.add(new SessionInfo("session-3", 1, 2));
- ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP, "Sample",
- false);
+ ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP, "Sample");
final Collection<ExecutionData> data = Collections.emptyList();
formatter.createReportVisitor(node, infos, data).visitEnd(null);
assertPathMatches("session-1", "/report/sessioninfo[1]/@id");
@@ -111,8 +110,8 @@ public class XMLFormatterTest {
final BufferedReader reader = new BufferedReader(new InputStreamReader(
output.getFileAsStream(), "UTF-8"));
final String line = reader.readLine();
- assertTrue(line, line
- .startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\""));
+ assertTrue(line,
+ line.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\""));
}
@Test
@@ -122,8 +121,8 @@ public class XMLFormatterTest {
final BufferedReader reader = new BufferedReader(new InputStreamReader(
output.getFileAsStream(), "UTF-16"));
final String line = reader.readLine();
- assertTrue(line, line
- .startsWith("<?xml version=\"1.0\" encoding=\"UTF-16\""));
+ assertTrue(line,
+ line.startsWith("<?xml version=\"1.0\" encoding=\"UTF-16\""));
}
private void assertPathMatches(String expected, String path)
diff --git a/org.jacoco.report.test/src/org/jacoco/report/xml/XMLReportNodeHandlerTest.java b/org.jacoco.report.test/src/org/jacoco/report/xml/XMLReportNodeHandlerTest.java
index c77fcf50..a6e7da20 100644
--- a/org.jacoco.report.test/src/org/jacoco/report/xml/XMLReportNodeHandlerTest.java
+++ b/org.jacoco.report.test/src/org/jacoco/report/xml/XMLReportNodeHandlerTest.java
@@ -22,6 +22,7 @@ import org.jacoco.core.analysis.CounterImpl;
import org.jacoco.core.analysis.CoverageNodeImpl;
import org.jacoco.core.analysis.ICoverageNode.ElementType;
import org.jacoco.core.analysis.MethodCoverage;
+import org.jacoco.core.analysis.SourceNodeImpl;
import org.jacoco.report.IReportVisitor;
import org.junit.Before;
import org.junit.Test;
@@ -51,7 +52,7 @@ public class XMLReportNodeHandlerTest {
root = new XMLDocument("report", "-//JACOCO//DTD Report 1.0//EN",
"report.dtd", "UTF-8", true, buffer);
handler = new XMLReportNodeHandler(root, new CoverageNodeImpl(
- ElementType.GROUP, "Sample", false));
+ ElementType.GROUP, "Sample"));
}
@Test
@@ -62,8 +63,7 @@ public class XMLReportNodeHandlerTest {
@Test
public void testGroup() throws Exception {
- handler.visitChild(
- new CoverageNodeImpl(ElementType.GROUP, "Group1", false))
+ handler.visitChild(new CoverageNodeImpl(ElementType.GROUP, "Group1"))
.visitEnd(null);
final Document doc = getDocument();
assertEquals("Group1", support.findStr(doc, "//report/group/@name"));
@@ -72,7 +72,7 @@ public class XMLReportNodeHandlerTest {
@Test
public void testCounters() throws Exception {
final CoverageNodeImpl node = new CoverageNodeImpl(ElementType.GROUP,
- "Group1", false) {
+ "Group1") {
{
classCounter = CounterImpl.getInstance(9, 1);
methodCounter = CounterImpl.getInstance(18, 2);
@@ -108,8 +108,8 @@ public class XMLReportNodeHandlerTest {
@Test
public void testPackage() throws Exception {
handler.visitChild(
- new CoverageNodeImpl(ElementType.PACKAGE, "org.jacoco.example",
- false)).visitEnd(null);
+ new CoverageNodeImpl(ElementType.PACKAGE, "org.jacoco.example"))
+ .visitEnd(null);
final Document doc = getDocument();
assertEquals("org.jacoco.example",
support.findStr(doc, "//report/package/@name"));
@@ -119,10 +119,9 @@ public class XMLReportNodeHandlerTest {
public void testClass() throws Exception {
final IReportVisitor packageHandler = handler
.visitChild(new CoverageNodeImpl(ElementType.PACKAGE,
- "org.jacoco.example", false));
- packageHandler.visitChild(
- new CoverageNodeImpl(ElementType.CLASS, "Foo", true)).visitEnd(
- null);
+ "org.jacoco.example"));
+ packageHandler.visitChild(new SourceNodeImpl(ElementType.CLASS, "Foo"))
+ .visitEnd(null);
packageHandler.visitEnd(null);
final Document doc = getDocument();
assertEquals("Foo",
@@ -133,13 +132,11 @@ public class XMLReportNodeHandlerTest {
public void testMethod() throws Exception {
final IReportVisitor packageHandler = handler
.visitChild(new CoverageNodeImpl(ElementType.PACKAGE,
- "org.jacoco.example", false));
+ "org.jacoco.example"));
final IReportVisitor classHandler = packageHandler
- .visitChild(new CoverageNodeImpl(ElementType.CLASS, "Foo", true));
+ .visitChild(new SourceNodeImpl(ElementType.CLASS, "Foo"));
MethodCoverage node = new MethodCoverage("doit", "()V", null);
- node.addInsn(false, 15);
- node.addInsn(false, 16);
- node.addInsn(false, 16);
+ node.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 15);
classHandler.visitChild(node).visitEnd(null);
classHandler.visitEnd(null);
packageHandler.visitEnd(null);
@@ -156,33 +153,26 @@ public class XMLReportNodeHandlerTest {
public void testSourcefile() throws Exception {
final IReportVisitor packageHandler = handler
.visitChild(new CoverageNodeImpl(ElementType.PACKAGE,
- "org.jacoco.example", false));
- final CoverageNodeImpl node = new CoverageNodeImpl(
- ElementType.SOURCEFILE, "Foo.java", true) {
- {
- lines.incrementInsn(11, false);
- lines.incrementInsn(13, false);
- lines.incrementInsn(13, true);
- lines.incrementInsn(14, true);
- }
- };
+ "org.jacoco.example"));
+ final SourceNodeImpl node = new SourceNodeImpl(ElementType.SOURCEFILE,
+ "Foo.java");
+ node.increment(CounterImpl.getInstance(1, 2),
+ CounterImpl.getInstance(3, 4), 12);
packageHandler.visitChild(node).visitEnd(null);
packageHandler.visitEnd(null);
final Document doc = getDocument();
assertEquals("Foo.java",
support.findStr(doc, "//report/package/sourcefile/@name"));
- assertEquals("11",
- support.findStr(doc, "//report/package/sourcefile/line[1]/@nr"));
- assertEquals("N", support.findStr(doc,
- "//report/package/sourcefile/line[1]/@status"));
- assertEquals("13",
- support.findStr(doc, "//report/package/sourcefile/line[2]/@nr"));
- assertEquals("P", support.findStr(doc,
- "//report/package/sourcefile/line[2]/@status"));
- assertEquals("14",
- support.findStr(doc, "//report/package/sourcefile/line[3]/@nr"));
- assertEquals("F", support.findStr(doc,
- "//report/package/sourcefile/line[3]/@status"));
+ assertEquals("12",
+ support.findStr(doc, "//report/package/sourcefile/line/@nr"));
+ assertEquals("1",
+ support.findStr(doc, "//report/package/sourcefile/line/@mi"));
+ assertEquals("2",
+ support.findStr(doc, "//report/package/sourcefile/line/@ci"));
+ assertEquals("3",
+ support.findStr(doc, "//report/package/sourcefile/line/@mb"));
+ assertEquals("4",
+ support.findStr(doc, "//report/package/sourcefile/line/@cb"));
}
private Document getDocument() throws SAXException, IOException,