CsvCoverageOutputter extends AbstractCoverageOutputter { @Override protected void exportCoverageInformation(IBPELCoverage c) throws IOException { for (IMetricCoverage metricCoverage : c.getMetricCoverages()) { String fileName = c.getProcessName().getLocalPart() + "." + metricCoverage.getMetricId() + ".csv"; File csvFile = new File(getOutputDirectory(), fileName); Writer writer = new FileWriter(csvFile); try { writer.write(String.format("Element%sMin%sMax%sTotal%sAvg%sCoverage\n", separator, separator, separator, separator, separator)); for (ICoverageResult result : metricCoverage .getCoverageResult()) { writer.write(String.format("%s%s%s%s%s%s%s%s%s%s%s\n", result.getBPELElementReference(), separator, result.min(), separator, result.max(), separator, result.getExecutionCount(), separator, result.avg(), separator, result.coverage() )); } } finally { IOUtils.closeQuietly(writer); } } }  @CoverageOutputOption(description="The separator used to delimit values") void setSeperator(String newSeperator);  }
@Test public void testOutput() throws IOException { initializeOutputDirectory("testOutput"); DummyCoverage coverage = DummyCoverage.createDummyCoverage("testOutput"); doc.getCoverageInformationForProcesses().add(coverage); outputter.exportCoverageInformation(doc); File[] files = outputDirectory.listFiles(); assertEquals(2, files.length); assertEquals("testOutput.Metric1.csv", files[0].getName()); assertEquals("testOutput.Metric2.csv", files[1].getName()); String actualContents = new String(FileUtil.readFile(files[0])); String expectedContents = new String(FileUtil.readFile(new File("src/test/resources/csvoutputter/testOutput.Metric1.csv"))); assertEquals(expectedContents, actualContents); actualContents = new String(FileUtil.readFile(files[1])); expectedContents = new String(FileUtil.readFile(new File("src/test/resources/csvoutputter/testOutput.Metric2.csv"))); assertEquals(expectedContents, actualContents); }