| Code with Finding: |
class EmailableReporter {
/**
* @param tests
*/
private void resultSummary(ISuite suite, IResultMap tests, String testname, String style,
String details) {
if (tests.getAllResults().size() > 0) {
StringBuffer buff = new StringBuffer();
String lastClassName = "";
int mq = 0;
int cq = 0;
for (ITestNGMethod method : getMethodSet(tests, suite)) {
m_row += 1;
m_methodIndex += 1;
ITestClass testClass = method.getTestClass();
String className = testClass.getName();
if (mq == 0) {
String id = (m_testIndex == null ? null : "t" + Integer.toString(m_testIndex));
titleRow(testname + " — " + style + details, 5, id);
m_testIndex = null;
}
if (!className.equalsIgnoreCase(lastClassName)) {
if (mq > 0) {
cq += 1;
m_out.print("<tr class=\"" + style
+ (cq % 2 == 0 ? "even" : "odd") + "\">" + "<td");
if (mq > 1) {
m_out.print(" rowspan=\"" + mq + "\"");
}
m_out.println(">" + lastClassName + "</td>" + buff);
}
mq = 0;
buff.setLength(0);
lastClassName = className;
}
Set<ITestResult> resultSet = tests.getResults(method);
long end = Long.MIN_VALUE;
long start = Long.MAX_VALUE;
for (ITestResult testResult : tests.getResults(method)) {
if (testResult.getEndMillis() > end) {
end = testResult.getEndMillis();
}
if (testResult.getStartMillis() < start) {
start = testResult.getStartMillis();
}
}
mq += 1;
if (mq > 1) {
buff.append("<tr class=\"" + style + (cq % 2 == 0 ? "odd" : "even")
+ "\">");
}
String description = method.getDescription();
String testInstanceName = resultSet.toArray(new ITestResult[]{})[0].getTestName();
buff.append("<td><a href=\"#m" + m_methodIndex + "\">"
+ qualifiedName(method)
+ " " + (description != null && description.length() > 0
? "(\"" + description + "\")"
: "")
+ "</a>" + (null == testInstanceName ? "" : "<br>(" + testInstanceName + ")")
+ "</td>"
+ "<td class=\"numi\">" + resultSet.size() + "</td>"
+ "<td>" + start + "</td>"
+ "<td class=\"numi\">" + (end - start) + "</td>"
+ "</tr>");
}
if (mq > 0) {
cq += 1;
m_out.print("<tr class=\"" + style + (cq % 2 == 0 ? "even" : "odd")
+ "\">" + "<td");
if (mq > 1) {
m_out.print(" rowspan=\"" + mq + "\"");
}
m_out.println(">" + lastClassName + "</td>" + buff);
}
}
}
}
|