Search in sources :

Example 1 with CSVFormatter

use of org.jacoco.report.csv.CSVFormatter 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 CSVFormatter

use of org.jacoco.report.csv.CSVFormatter in project jacoco by jacoco.

the class ReportSupport method addCsvFormatter.

public void addCsvFormatter(final File targetfile, final String encoding) throws IOException {
    final CSVFormatter csv = new CSVFormatter();
    csv.setOutputEncoding(encoding);
    formatters.add(csv.createVisitor(new FileOutputStream(targetfile)));
}
Also used : FileOutputStream(java.io.FileOutputStream) CSVFormatter(org.jacoco.report.csv.CSVFormatter)

Example 3 with CSVFormatter

use of org.jacoco.report.csv.CSVFormatter 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)

Aggregations

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