Map<String, ISuiteResult> redResults = Maps.newHashMap();
Map<String, ISuiteResult> yellowResults = Maps.newHashMap();
Map<String, ISuiteResult> greenResults = Maps.newHashMap();
for (String suiteName : suiteResults.keySet()) {
ISuiteResult sr = suiteResults.get(suiteName);
ITestContext tc = sr.getTestContext();
int failed = tc.getFailedTests().size();
int skipped = tc.getSkippedTests().size();
int passed = tc.getPassedTests().size();
if (failed > 0) {
redResults.put(suiteName, sr);
}
else if (skipped > 0) {
yellowResults.put(suiteName, sr);
}
else if (passed > 0) {
greenResults.put(suiteName, sr);
}
else {
redResults.put(suiteName, sr);
}
}
ISuiteResult[][] results = new ISuiteResult[][] {
sortResults(redResults.values()), sortResults(yellowResults.values()), sortResults(greenResults.values())
};
String[] colors = {"failed", "skipped", "passed"};
for (int i = 0; i < colors.length; i++) {
ISuiteResult[] r = results[i];
for (ISuiteResult sr: r) {
String suiteName = sr.getTestContext().getName();
generateSuiteResult(suiteName, sr, colors[i], tableOfContents, m_outputDirectory);
}
}
tableOfContents.append("</body></html>");