use of org.jacoco.core.analysis.IMethodCoverage in project jacoco by jacoco.
the class ClassAnalyzer method visitMethod.
@Override
public MethodProbesVisitor visitMethod(final int access, final String name, final String desc, final String signature, final String[] exceptions) {
InstrSupport.assertNotInstrumented(name, coverage.getName());
return new MethodAnalyzer(coverage.getName(), coverage.getSuperName(), stringPool.get(name), stringPool.get(desc), stringPool.get(signature), probes, Filters.ALL) {
@Override
public void visitEnd() {
super.visitEnd();
final IMethodCoverage methodCoverage = getCoverage();
if (methodCoverage.getInstructionCounter().getTotalCount() > 0) {
// Only consider methods that actually contain code
coverage.addMethod(methodCoverage);
}
}
};
}
use of org.jacoco.core.analysis.IMethodCoverage in project jacoco by jacoco.
the class CyclomaticComplexityTest method analyze.
private ICounter analyze() throws IOException {
final CoverageBuilder builder = new CoverageBuilder();
final ExecutionDataStore store = new ExecutionDataStore();
data.collect(store, new SessionInfoStore(), false);
final Analyzer analyzer = new Analyzer(store, builder);
analyzer.analyzeClass(bytes, "TestTarget");
final Collection<IClassCoverage> classes = builder.getClasses();
assertEquals(1, classes.size(), 0.0);
final IClassCoverage classCoverage = classes.iterator().next();
for (final IMethodCoverage m : classCoverage.getMethods()) {
if (m.getName().equals("test")) {
return m.getComplexityCounter();
}
}
throw new AssertionError("No test() method.");
}
Aggregations