Search in sources :

Example 1 with HTMLFormatter

use of org.jacoco.report.html.HTMLFormatter in project buck by facebook.

the class ReportGenerator method createReport.

private void createReport(final IBundleCoverage bundleCoverage) throws IOException {
    // Create a concrete report visitor based on some supplied
    // configuration. In this case we use the defaults
    IReportVisitor visitor;
    switch(reportFormat) {
        case "csv":
            reportDirectory.mkdirs();
            CSVFormatter csvFormatter = new CSVFormatter();
            visitor = csvFormatter.createVisitor(new FileOutputStream(new File(reportDirectory, "coverage.csv")));
            break;
        case "html":
            HTMLFormatter htmlFormatter = new HTMLFormatter();
            visitor = htmlFormatter.createVisitor(new FileMultiReportOutput(reportDirectory));
            break;
        case "xml":
            reportDirectory.mkdirs();
            XMLFormatter xmlFormatter = new XMLFormatter();
            visitor = xmlFormatter.createVisitor(new FileOutputStream(new File(reportDirectory, "coverage.xml")));
            break;
        default:
            throw new RuntimeException("Unable to parse format: " + reportFormat);
    }
    // Initialize the report with all of the execution and session
    // information. At this point the report doesn't know about the
    // structure of the report being created
    visitor.visitInfo(execFileLoader.getSessionInfoStore().getInfos(), execFileLoader.getExecutionDataStore().getContents());
    // Populate the report structure with the bundle coverage information.
    // Call visitGroup if you need groups in your report.
    visitor.visitBundle(bundleCoverage, createSourceFileLocator());
    // Signal end of structure information to allow report to write all
    // information out
    visitor.visitEnd();
}
Also used : FileMultiReportOutput(org.jacoco.report.FileMultiReportOutput) XMLFormatter(org.jacoco.report.xml.XMLFormatter) FileOutputStream(java.io.FileOutputStream) HTMLFormatter(org.jacoco.report.html.HTMLFormatter) CSVFormatter(org.jacoco.report.csv.CSVFormatter) File(java.io.File) IReportVisitor(org.jacoco.report.IReportVisitor)

Example 2 with HTMLFormatter

use of org.jacoco.report.html.HTMLFormatter in project jacoco by jacoco.

the class Report method createReportVisitor.

private IReportVisitor createReportVisitor() throws IOException, IOException {
    final List<IReportVisitor> visitors = new ArrayList<IReportVisitor>();
    if (xml != null) {
        final XMLFormatter formatter = new XMLFormatter();
        visitors.add(formatter.createVisitor(new FileOutputStream(xml)));
    }
    if (csv != null) {
        final CSVFormatter formatter = new CSVFormatter();
        visitors.add(formatter.createVisitor(new FileOutputStream(csv)));
    }
    if (html != null) {
        final HTMLFormatter formatter = new HTMLFormatter();
        visitors.add(formatter.createVisitor(new FileMultiReportOutput(html)));
    }
    return new MultiReportVisitor(visitors);
}
Also used : FileMultiReportOutput(org.jacoco.report.FileMultiReportOutput) MultiReportVisitor(org.jacoco.report.MultiReportVisitor) XMLFormatter(org.jacoco.report.xml.XMLFormatter) FileOutputStream(java.io.FileOutputStream) HTMLFormatter(org.jacoco.report.html.HTMLFormatter) ArrayList(java.util.ArrayList) CSVFormatter(org.jacoco.report.csv.CSVFormatter) IReportVisitor(org.jacoco.report.IReportVisitor)

Example 3 with HTMLFormatter

use of org.jacoco.report.html.HTMLFormatter in project jacoco by jacoco.

the class ReportGenerator method createReport.

private void createReport(final IBundleCoverage bundleCoverage) throws IOException {
    // Create a concrete report visitor based on some supplied
    // configuration. In this case we use the defaults
    final HTMLFormatter htmlFormatter = new HTMLFormatter();
    final IReportVisitor visitor = htmlFormatter.createVisitor(new FileMultiReportOutput(reportDirectory));
    // Initialize the report with all of the execution and session
    // information. At this point the report doesn't know about the
    // structure of the report being created
    visitor.visitInfo(execFileLoader.getSessionInfoStore().getInfos(), execFileLoader.getExecutionDataStore().getContents());
    // Populate the report structure with the bundle coverage information.
    // Call visitGroup if you need groups in your report.
    visitor.visitBundle(bundleCoverage, new DirectorySourceFileLocator(sourceDirectory, "utf-8", 4));
    // Signal end of structure information to allow report to write all
    // information out
    visitor.visitEnd();
}
Also used : FileMultiReportOutput(org.jacoco.report.FileMultiReportOutput) DirectorySourceFileLocator(org.jacoco.report.DirectorySourceFileLocator) HTMLFormatter(org.jacoco.report.html.HTMLFormatter) IReportVisitor(org.jacoco.report.IReportVisitor)

Example 4 with HTMLFormatter

use of org.jacoco.report.html.HTMLFormatter in project jacoco by jacoco.

the class ReportSupport method addHtmlFormatter.

public void addHtmlFormatter(final File targetdir, final String encoding, final String footer, final Locale locale) throws IOException {
    final HTMLFormatter htmlFormatter = new HTMLFormatter();
    htmlFormatter.setOutputEncoding(encoding);
    htmlFormatter.setLocale(locale);
    if (footer != null) {
        htmlFormatter.setFooterText(footer);
    }
    formatters.add(htmlFormatter.createVisitor(new FileMultiReportOutput(targetdir)));
}
Also used : FileMultiReportOutput(org.jacoco.report.FileMultiReportOutput) HTMLFormatter(org.jacoco.report.html.HTMLFormatter)

Aggregations

FileMultiReportOutput (org.jacoco.report.FileMultiReportOutput)4 HTMLFormatter (org.jacoco.report.html.HTMLFormatter)4 IReportVisitor (org.jacoco.report.IReportVisitor)3 FileOutputStream (java.io.FileOutputStream)2 CSVFormatter (org.jacoco.report.csv.CSVFormatter)2 XMLFormatter (org.jacoco.report.xml.XMLFormatter)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 DirectorySourceFileLocator (org.jacoco.report.DirectorySourceFileLocator)1 MultiReportVisitor (org.jacoco.report.MultiReportVisitor)1