Code with Finding: |
class XMLReporter { private Properties getSuiteAttributes(ISuite suite) { Properties props = new Properties(); props.setProperty(XMLReporterConfig.ATTR_NAME, suite.getName());
// Calculate the duration Map<String, ISuiteResult> results = suite.getResults(); Date minStartDate = new Date(); Date maxEndDate = null; // TODO: We could probably optimize this in order not to traverse this twice for (Map.Entry<String, ISuiteResult> result : results.entrySet()) { ITestContext testContext = result.getValue().getTestContext(); Date startDate = testContext.getStartDate(); Date endDate = testContext.getEndDate(); if (minStartDate.after(startDate)) { minStartDate = startDate; } if (maxEndDate == null || maxEndDate.before(endDate)) { maxEndDate = endDate != null ? endDate : startDate; } }
// The suite could be completely empty if (maxEndDate == null) { maxEndDate = minStartDate; } addDurationAttributes(config, props, minStartDate, maxEndDate); return props; }
}
|