org.testng.reporters.SuiteHTMLReporter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testng Show documentation
Show all versions of testng Show documentation
Testing framework for Java
package org.testng.reporters;
import static org.testng.internal.Utils.isStringNotEmpty;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.testng.IInvokedMethod;
import org.testng.IReporter;
import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestClass;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
import org.testng.Reporter;
import org.testng.collections.Maps;
import org.testng.internal.Utils;
import org.testng.log4testng.Logger;
import org.testng.xml.XmlSuite;
/**
* This class implements an HTML reporter for suites.
*
* @author cbeust
* @author Alexandru Popescu
*/
public class SuiteHTMLReporter implements IReporter {
public static final String METHODS_CHRONOLOGICAL = "methods.html";
public static final String METHODS_ALPHABETICAL = "methods-alphabetical.html";
public static final String GROUPS = "groups.html";
public static final String CLASSES = "classes.html";
public static final String REPORTER_OUTPUT = "reporter-output.html";
public static final String METHODS_NOT_RUN = "methods-not-run.html";
public static final String TESTNG_XML = "testng.xml.html";
private static final String TD_A_TARGET_MAIN_FRAME_HREF = "")
.append(title)
.append("\n")
.append("")
.append(
"Suite Passed Failed Skipped testng.xml \n");
int totalFailedTests = 0;
int totalPassedTests = 0;
int totalSkippedTests = 0;
StringBuilder suiteBuf = new StringBuilder();
for (ISuite suite : suites) {
if (suite.getResults().size() == 0) {
continue;
}
String name = suite.getName();
int failedTests = 0;
int passedTests = 0;
int skippedTests = 0;
Map results = suite.getResults();
for (ISuiteResult result : results.values()) {
ITestContext context = result.getTestContext();
failedTests += context.getFailedTests().size();
totalFailedTests += context.getFailedTests().size();
passedTests += context.getPassedTests().size();
totalPassedTests += context.getPassedTests().size();
skippedTests += context.getSkippedTests().size();
totalSkippedTests += context.getSkippedTests().size();
}
String cls =
failedTests > 0
? "invocation-failed"
: (passedTests > 0 ? "invocation-passed" : "invocation-failed");
suiteBuf
.append("")
.append("")
.append(name)
.append(" \n");
suiteBuf
.append("")
.append(passedTests)
.append(CLOSE_TD)
.append(" ")
.append(failedTests)
.append(CLOSE_TD)
.append(" ")
.append(skippedTests)
.append(CLOSE_TD)
.append(" Link")
.append(" ")
.append(" ");
}
String cls =
totalFailedTests > 0
? "invocation-failed"
: (totalPassedTests > 0 ? "invocation-passed" : "invocation-failed");
sb.append("")
.append("Total ")
.append("")
.append(totalPassedTests)
.append(" ")
.append("")
.append(totalFailedTests)
.append(" ")
.append("")
.append(totalSkippedTests)
.append(" ")
.append(" ")
.append(" \n");
sb.append(suiteBuf);
sb.append("
").append("