/** Obtains the detailed {@link CoverageReport} instance. */ public synchronized CoverageReport getResult() { if (report != null) { final CoverageReport r = report.get(); if (r != null) return r; } final JacocoReportDir reportFolder = getJacocoReport(); try { CoverageReport r = new CoverageReport(this, reportFolder.parse(inclusions, exclusions)); report = new WeakReference<CoverageReport>(r); r.setThresholds(thresholds); return r; } catch (IOException e) { logger.println("Failed to load " + reportFolder); e.printStackTrace(logger); return null; } }
/** * Extracts top-level coverage information from the JaCoCo report document. * * @param layout * @param ratios * @return * @throws IOException */ private static Map<Type, Coverage> loadRatios( JacocoReportDir layout, Map<Type, Coverage> ratios, String[] includes, String[] excludes) throws IOException { if (ratios == null) { ratios = new LinkedHashMap<CoverageElement.Type, Coverage>(); } ExecutionFileLoader efl = layout.parse(includes, excludes); IBundleCoverage bundleCoverage = efl.getBundleCoverage(); Coverage ratio = new Coverage(); ratio.accumulatePP( bundleCoverage.getClassCounter().getMissedCount(), bundleCoverage.getClassCounter().getCoveredCount()); ratios.put(CoverageElement.Type.CLASS, ratio); ratio = new Coverage(); ratio.accumulatePP( bundleCoverage.getBranchCounter().getMissedCount(), bundleCoverage.getBranchCounter().getCoveredCount()); ratios.put(CoverageElement.Type.BRANCH, ratio); ratio = new Coverage(); ratio.accumulatePP( bundleCoverage.getInstructionCounter().getMissedCount(), bundleCoverage.getInstructionCounter().getCoveredCount()); ratios.put(CoverageElement.Type.INSTRUCTION, ratio); ratio = new Coverage(); ratio.accumulatePP( bundleCoverage.getMethodCounter().getMissedCount(), bundleCoverage.getMethodCounter().getCoveredCount()); ratios.put(CoverageElement.Type.METHOD, ratio); ratio = new Coverage(); ratio.accumulatePP( bundleCoverage.getComplexityCounter().getMissedCount(), bundleCoverage.getComplexityCounter().getCoveredCount()); ratios.put(CoverageElement.Type.COMPLEXITY, ratio); ratio = new Coverage(); ratio.accumulatePP( bundleCoverage.getLineCounter().getMissedCount(), bundleCoverage.getLineCounter().getCoveredCount()); ratios.put(CoverageElement.Type.LINE, ratio); // logGer.log(Level.INFO, ratios.toString()); return ratios; }