use of org.jacoco.core.analysis.Analyzer 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.Analyzer 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.Analyzer 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);
}
use of org.jacoco.core.analysis.Analyzer in project dspot by STAMP-project.
the class JacocoExecutor method coverageResults.
private CoverageResults coverageResults(ExecutionDataStore executionData) {
final String classesDirectory = this.program.getProgramDir() + "/" + this.program.getClassesDir();
final CoverageBuilder coverageBuilder = new CoverageBuilder();
final Analyzer analyzer = new Analyzer(executionData, coverageBuilder);
try {
analyzer.analyzeAll(new File(classesDirectory));
} catch (IOException e) {
throw new RuntimeException(e);
}
return new CoverageResults(coverageBuilder);
}
Aggregations