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();
}
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)));
}
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);
}
Aggregations