use of org.jacoco.core.analysis.CoverageBuilder in project powermock by powermock.
the class JacocoCoverageTest method collectCoverage.
private CoverageBuilder collectCoverage(ExecutionDataStore executionData) throws IOException {
final CoverageBuilder coverageBuilder = new CoverageBuilder();
final Analyzer analyzer = new Analyzer(executionData, coverageBuilder);
for (String className : TARGET) {
analyzer.analyzeClass(getClass().getResourceAsStream(classNameToFileName(className)), className);
}
return coverageBuilder;
}
use of org.jacoco.core.analysis.CoverageBuilder in project powermock by powermock.
the class JacocoCoverageTest method jacocoOfflineInstShouldCalculateCoverageAfterPowerMockTransformation.
@Test
public void jacocoOfflineInstShouldCalculateCoverageAfterPowerMockTransformation() throws Exception {
final RuntimeData data = new RuntimeData();
runTargetTest(data);
final CoverageBuilder coverageBuilder = collectCoverage(getExecutionDataStore(data));
assertCodeCoverage(coverageBuilder);
}
use of org.jacoco.core.analysis.CoverageBuilder in project jacoco by jacoco.
the class ReportTask method createBundle.
private IBundleCoverage createBundle(final GroupElement group) throws IOException {
final CoverageBuilder builder = new CoverageBuilder();
final Analyzer analyzer = new Analyzer(executionDataStore, builder);
for (final Iterator<?> i = group.classfiles.iterator(); i.hasNext(); ) {
final Resource resource = (Resource) i.next();
if (resource.isDirectory() && resource instanceof FileResource) {
analyzer.analyzeAll(((FileResource) resource).getFile());
} else {
final InputStream in = resource.getInputStream();
analyzer.analyzeAll(in, resource.getName());
in.close();
}
}
final IBundleCoverage bundle = builder.getBundle(group.name);
logBundleInfo(bundle, builder.getNoMatchClasses());
return bundle;
}
use of org.jacoco.core.analysis.CoverageBuilder 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.");
}
use of org.jacoco.core.analysis.CoverageBuilder in project jacoco by jacoco.
the class ReportSupport method processProject.
private void processProject(final IReportGroupVisitor visitor, final String bundeName, final MavenProject project, final List<String> includes, final List<String> excludes, final ISourceFileLocator locator) throws IOException {
final CoverageBuilder builder = new CoverageBuilder();
final File classesDir = new File(project.getBuild().getOutputDirectory());
if (classesDir.isDirectory()) {
final Analyzer analyzer = new Analyzer(loader.getExecutionDataStore(), builder);
final FileFilter filter = new FileFilter(includes, excludes);
for (final File file : filter.getFiles(classesDir)) {
analyzer.analyzeAll(file);
}
}
final IBundleCoverage bundle = builder.getBundle(bundeName);
logBundleInfo(bundle, builder.getNoMatchClasses());
visitor.visitBundle(bundle, locator);
}
Aggregations