use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class BundlePageTest method should_render_non_empty_packages.
@Test
public void should_render_non_empty_packages() throws Exception {
final ClassCoverageImpl classCoverage = new ClassCoverageImpl("example/Class", 0, false);
final MethodCoverageImpl methodCoverage = new MethodCoverageImpl("m", "()V", null);
methodCoverage.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
classCoverage.addMethod(methodCoverage);
final IPackageCoverage nonEmptyPackage = new PackageCoverageImpl("example", Collections.<IClassCoverage>singleton(classCoverage), Collections.<ISourceFileCoverage>emptySet());
final IPackageCoverage emptyPackage = new PackageCoverageImpl("empty", Collections.<IClassCoverage>emptySet(), Collections.<ISourceFileCoverage>emptySet());
final IBundleCoverage node = new BundleCoverageImpl("bundle", Arrays.asList(nonEmptyPackage, emptyPackage));
final BundlePage page = new BundlePage(node, null, null, rootFolder, context);
page.render();
final Document doc = support.parse(output.getFile("index.html"));
assertEquals("el_package", support.findStr(doc, "/html/body/table[1]/tbody/tr[1]/td[1]/a/@class"));
assertEquals("example", 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 ClassPageTest method should_generate_message_with_default_package_when_SourceFileName_present_but_no_SourceFilePage.
@Test
public void should_generate_message_with_default_package_when_SourceFileName_present_but_no_SourceFilePage() throws Exception {
final MethodCoverageImpl m = new MethodCoverageImpl("a", "()V", null);
m.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
node = new ClassCoverageImpl("Foo", 123, false);
node.addMethod(m);
node.setSourceFileName("Foo.java");
page = new ClassPage(node, null, null, rootFolder, context);
page.render();
final Document doc = support.parse(output.getFile("Foo.html"));
assertEquals("Source file \"Foo.java\" was not found during generation of report.", support.findStr(doc, "/html/body/p[1]"));
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class ClassPageTest method setup.
@Before
@Override
public void setup() throws Exception {
super.setup();
final MethodCoverageImpl m = new MethodCoverageImpl("a", "()V", null);
m.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 42);
node = new ClassCoverageImpl("org/jacoco/example/Foo", 123, false);
node.addMethod(m);
node.addMethod(new MethodCoverageImpl("b", "()V", null));
node.addMethod(new MethodCoverageImpl("c", "()V", null));
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class BundleCheckerTest method createBundle.
private IBundleCoverage createBundle() {
final MethodCoverageImpl m = new MethodCoverageImpl("fooMethod", "()V", null);
m.increment(CounterImpl.getInstance(5, 5), CounterImpl.COUNTER_0_0, 1);
m.incrementMethodCounter();
final ClassCoverageImpl c = new ClassCoverageImpl("org/jacoco/example/FooClass", 1001, false);
c.setSourceFileName("FooClass.java");
c.addMethod(m);
final SourceFileCoverageImpl s = new SourceFileCoverageImpl("FooClass.java", "org/jacoco/example");
s.increment(c);
IPackageCoverage p = new PackageCoverageImpl("org/jacoco/example", Collections.singleton((IClassCoverage) c), Collections.singleton((ISourceFileCoverage) s));
return new BundleCoverageImpl("Test", Collections.singleton(p));
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class CoverageBuilderTest method testCreateClassCovered.
@Test
public void testCreateClassCovered() {
final MethodCoverageImpl method = new MethodCoverageImpl("doit", "()V", null);
method.increment(CounterImpl.COUNTER_0_1, CounterImpl.COUNTER_0_0, 6);
method.increment(CounterImpl.COUNTER_0_1, CounterImpl.COUNTER_0_0, 7);
method.increment(CounterImpl.COUNTER_0_1, CounterImpl.COUNTER_0_0, 8);
method.incrementMethodCounter();
addClass(123L, false, "Sample", null, method);
final Collection<IClassCoverage> classes = coverageBuilder.getClasses();
assertEquals(1, classes.size());
IClassCoverage c = classes.iterator().next();
assertEquals("Sample", c.getName());
assertEquals(1, c.getClassCounter().getTotalCount());
assertEquals(1, c.getClassCounter().getCoveredCount());
assertEquals(1, c.getMethodCounter().getTotalCount());
assertEquals(1, c.getMethodCounter().getCoveredCount());
assertEquals(3, c.getLineCounter().getTotalCount());
assertEquals(3, c.getLineCounter().getCoveredCount());
final Collection<IMethodCoverage> methods = c.getMethods();
assertEquals(1, methods.size());
IMethodCoverage m = methods.iterator().next();
assertEquals("doit", m.getName());
assertEquals("()V", m.getDesc());
assertEquals(1, m.getMethodCounter().getTotalCount());
assertEquals(1, m.getMethodCounter().getCoveredCount());
assertEquals(3, m.getLineCounter().getTotalCount());
assertEquals(3, m.getLineCounter().getCoveredCount());
}
Aggregations