Skip to content

Commit

Permalink
Polish XmlReportsWritingListener
Browse files Browse the repository at this point in the history
- Set reportData to null when the test plan is finished to allow for
  garbage collection
- Rename method handleException to printException to better state what
  it's doing
- Inline message variables to printException for brevity

Issue: #86
  • Loading branch information
marcphilipp committed Jan 27, 2016
1 parent 37cd4da commit 356fe6d
Showing 1 changed file with 8 additions and 5 deletions.
Expand Up @@ -49,11 +49,15 @@ public void testPlanExecutionStarted(TestPlan testPlan) {
Files.createDirectories(reportsDir.toPath());
}
catch (IOException e) {
String message = "Could not create report directory: " + reportsDir;
handleException(e, message);
printException("Could not create report directory: " + reportsDir, e);
}
}

@Override
public void testPlanExecutionFinished(TestPlan testPlan) {
this.reportData = null;
}

@Override
public void executionSkipped(TestIdentifier testIdentifier, String reason) {
reportData.markSkipped(testIdentifier, reason);
Expand All @@ -79,16 +83,15 @@ private void writeXmlReportSafely(TestIdentifier testIdentifier) {
new XmlReportWriter(reportData).writeXmlReport(testIdentifier, xmlFile);
}
catch (XMLStreamException | IOException e) {
String message = "Could not write file: " + xmlFile;
handleException(e, message);
printException("Could not write file: " + xmlFile, e);
}
}

private boolean isARoot(TestIdentifier testIdentifier) {
return !testIdentifier.getParentId().isPresent();
}

private void handleException(Exception exception, String message) {
private void printException(String message, Exception exception) {
out.println(message);
exception.printStackTrace(out);
}
Expand Down

0 comments on commit 356fe6d

Please sign in to comment.