use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class CoverageBuilderTest method testDuplicateClassNameIdentical.
@Test
public void testDuplicateClassNameIdentical() {
MethodCoverageImpl method = new MethodCoverageImpl("doit", "()V", null);
method.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 3);
addClass(123L, false, "Sample", null, method);
// Add class with same id:
method = new MethodCoverageImpl("doit", "()V", null);
method.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 3);
addClass(123L, false, "Sample", null, method);
// Second add must be ignored:
final Collection<IClassCoverage> classes = coverageBuilder.getClasses();
assertEquals(1, classes.size());
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class CoverageBuilderTest method testCreateSourceFile.
@Test
public void testCreateSourceFile() {
final MethodCoverageImpl method1 = new MethodCoverageImpl("doit", "()V", null);
method1.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 3);
addClass(123L, false, "Sample", "Sample.java", method1);
final MethodCoverageImpl method2 = new MethodCoverageImpl("doit", "()V", null);
method2.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 6);
addClass(234L, false, "Second", "Sample.java", method2);
final Collection<ISourceFileCoverage> sourcefiles = coverageBuilder.getSourceFiles();
assertEquals(1, sourcefiles.size());
ISourceFileCoverage s = sourcefiles.iterator().next();
assertEquals(2, s.getClassCounter().getTotalCount());
assertEquals(0, s.getClassCounter().getCoveredCount());
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class CoverageBuilderTest method testGetNoMatchClasses.
@Test
public void testGetNoMatchClasses() {
MethodCoverageImpl m = new MethodCoverageImpl("doit", "()V", null);
m.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 1);
addClass(1, true, "Sample1", null, m);
m = new MethodCoverageImpl("doit", "()V", null);
m.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 2);
addClass(2, true, "Sample2", null, m);
m = new MethodCoverageImpl("doit", "()V", null);
m.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 3);
addClass(3, false, "Sample3", null, m);
final Set<String> actual = getNames(coverageBuilder.getNoMatchClasses());
final Set<String> expected = new HashSet<String>(Arrays.asList("Sample1", "Sample2"));
assertEquals(expected, actual);
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class CoverageBuilderTest method testDuplicateClassNameDifferent.
@Test(expected = IllegalStateException.class)
public void testDuplicateClassNameDifferent() {
MethodCoverageImpl method = new MethodCoverageImpl("doit", "()V", null);
method.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 3);
addClass(123L, false, "Sample", null, method);
// Add class with different id must fail:
method = new MethodCoverageImpl("doit", "()V", null);
method.increment(CounterImpl.COUNTER_1_0, CounterImpl.COUNTER_0_0, 3);
addClass(345L, false, "Sample", null, method);
}
use of org.jacoco.core.internal.analysis.MethodCoverageImpl in project jacoco by jacoco.
the class ClassPageTest method should_generate_message_when_class_id_mismatch.
@Test
public void should_generate_message_when_class_id_mismatch() throws Exception {
node = new ClassCoverageImpl("Foo", 123, true);
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("A different version of class was executed at runtime.", support.findStr(doc, "/html/body/p[1]"));
}
Aggregations