use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class ClassPageTest method should_generate_message_when_no_lines.
@Test
public void should_generate_message_when_no_lines() throws Exception {
node = new ClassCoverageImpl("Foo", 123, false);
node.addMethod(new MethodCoverageImpl("m", "()V", null));
page = new ClassPage(node, null, new SourceLink(), rootFolder, context);
page.render();
final Document doc = support.parse(output.getFile("Foo.html"));
assertEquals("Class files must be compiled with debug information to show line coverage.", support.findStr(doc, "/html/body/p[1]"));
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class PackagePageTest method should_render_non_empty_classes.
@Test
public void should_render_non_empty_classes() throws Exception {
final ClassCoverageImpl nonEmptyClass = new ClassCoverageImpl("example/NonEmptyClass", 0, false);
final MethodCoverageImpl nonEmptyMethod = new MethodCoverageImpl("m", "()V", null);
nonEmptyMethod.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
nonEmptyClass.addMethod(nonEmptyMethod);
final ClassCoverageImpl emptyClass = new ClassCoverageImpl("example/EmptyClass", 0, false);
node = new PackageCoverageImpl("example", Arrays.<IClassCoverage>asList(emptyClass, nonEmptyClass), Collections.<ISourceFileCoverage>emptySet());
page = new PackagePage(node, null, sourceLocator, rootFolder, context);
page.render();
final Document doc = support.parse(output.getFile("index.html"));
assertEquals("NonEmptyClass", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a"));
assertEquals("1", support.findStr(doc, "count(/html/body/table[1]/tbody/tr)"));
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class PackagePageTest method testContentsWithSource.
@Test
public void testContentsWithSource() throws Exception {
ClassCoverageImpl class1 = new ClassCoverageImpl("org/jacoco/example/Foo1", 0x1000, false);
MethodCoverageImpl method1 = new MethodCoverageImpl("m", "()V", null);
method1.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
class1.addMethod(method1);
ClassCoverageImpl class2 = new ClassCoverageImpl("org/jacoco/example/Foo2", 0x2000, false);
MethodCoverageImpl method2 = new MethodCoverageImpl("m", "()V", null);
method2.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
class2.addMethod(method2);
ISourceFileCoverage src1 = new SourceFileCoverageImpl("Src1.java", "org/jacoco/example");
node = new PackageCoverageImpl("org/jacoco/example", Arrays.<IClassCoverage>asList(class1, class2), Arrays.asList(src1));
page = new PackagePage(node, null, sourceLocator, rootFolder, context);
page.render();
final Document doc = support.parse(output.getFile("index.html"));
// Expect "Source Files" links
assertEquals("index.source.html", support.findStr(doc, "/html/body/div[1]/span[1]/a/@href"));
assertEquals("el_source", support.findStr(doc, "/html/body/div[1]/span[1]/a/@class"));
assertEquals("Source Files", support.findStr(doc, "/html/body/div[1]/span[1]/a"));
assertEquals("el_class", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a/@class"));
assertEquals("Foo1", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a"));
assertEquals("el_class", support.findStr(doc, "/html/body/table[1]/tbody/tr[2]/td[1]/a/@class"));
assertEquals("Foo2", support.findStr(doc, "/html/body/table[1]/tbody/tr[2]/td[1]/a"));
output.assertFile("index.source.html");
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class PackagePageTest method testContentsNoSource.
@Test
public void testContentsNoSource() throws Exception {
ClassCoverageImpl class1 = new ClassCoverageImpl("org/jacoco/example/Foo1", 0x1000, false);
MethodCoverageImpl method1 = new MethodCoverageImpl("m", "()V", null);
method1.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
class1.addMethod(method1);
ClassCoverageImpl class2 = new ClassCoverageImpl("org/jacoco/example/Foo2", 0x2000, false);
MethodCoverageImpl method2 = new MethodCoverageImpl("m", "()V", null);
method2.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
class2.addMethod(method2);
node = new PackageCoverageImpl("org/jacoco/example", Arrays.<IClassCoverage>asList(class1, class2), Collections.<ISourceFileCoverage>emptyList());
page = new PackagePage(node, null, sourceLocator, rootFolder, context);
page.render();
// Expect no "Source Files" link
final Document doc = support.parse(output.getFile("index.html"));
assertEquals("Sessions", support.findStr(doc, "/html/body/div[1]/span[1]/a"));
// Expect no source files page:
output.assertNoFile("index.source.html");
}
Aggregations