/** * 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; }
/** Parses the saved "jacoco.exec" files into an {@link ExecutionFileLoader}. */ public ExecutionFileLoader parse(String[] includes, String[] excludes) throws IOException { ExecutionFileLoader efl = new ExecutionFileLoader(); for (File exec : getExecFiles()) { efl.addExecFile(new FilePath(exec)); } efl.setIncludes(includes); efl.setExcludes(excludes); efl.setClassDir(new FilePath(getClassesDir())); efl.setSrcDir(new FilePath(getSourcesDir())); efl.loadBundleCoverage(); return efl; }