private void reportResults(JsTestResults results) {
for(ReportType report : reports) {
JsTestResultReporter reporter;
//pick a reporter implementation
if(report.getType().trim().equalsIgnoreCase("plain")) {
reporter = new PlainReporter();
} else {
//default to plain reporter
reporter = new PlainReporter();
}
if(report.getDestFile() == null) {
error("Could not write a report, destFile attribute was not set");
continue;
}
try {
log("Writing report to " + report.getDestFile().getAbsolutePath());
File outFile = report.getDestFile();
Files.createParentDirs(outFile);
Files.touch(outFile);
Files.write(reporter.createReport(results), outFile, Charsets.UTF_8);
} catch (IOException e) {
error("Could not write report file: " + e.getMessage());
}
}
}