Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
\n")
// ;
String result = sb.toString();
return result;
}
private String dumpMethods(ITestNGMethod[] testMethods) {
StringBuffer sb = new StringBuffer();
if(null == testMethods || testMethods.length == 0) {
return "";
}
for (ITestNGMethod m : testMethods) {
sb.append("
\n");
sb.append("
\n")
.append("
").append(m.getMethodName()).append("
\n")
;
String[] groups = m.getGroups();
if (groups != null && groups.length > 0) {
sb.append("
");
for (String g : groups) {
sb.append(g).append(" ");
}
sb.append("
\n");
}
else {
sb.append("
");
}
sb.append("
\n");
}
// StringBuffer sb = new StringBuffer(" "); //"
");
// for (ITestNGMethod tm : testMethods) {
// sb
// .append(SP4).append(tm.getMethodName()).append("()\n")
// .append(dumpGroups(tm.getGroups()))
// .append(" ");
// ;
// }
String result = sb.toString();
return result;
}
private String dumpGroups(String[] groups) {
StringBuffer sb = new StringBuffer();
if (null != groups && groups.length > 0) {
sb.append(SP4).append("[");
for (String g : groups) {
sb.append(g).append(" ");
}
sb.append("] \n");
}
String result = sb.toString();
return result;
}
/**
* Generate information about the methods that were run
*/
public static final String AFTER= "<<";
public static final String BEFORE = ">>";
private void generateMethodsChronologically(XmlSuite xmlSuite, ISuite suite,
String outputFileName, boolean alphabetical)
{
try (BufferedWriter bw = Utils.openWriter(getOutputDirectory(xmlSuite), outputFileName)) {
bw.append("
Methods run, sorted chronologically
");
bw.append("
" + BEFORE + " means before, " + AFTER + " means after
");
long startDate = -1;
bw.append(" ").append(suite.getName()).append("");
bw.append("(Hover the method name to see the test class name)\n");
Collection invokedMethods = suite.getAllInvokedMethods();
if (alphabetical) {
@SuppressWarnings({"unchecked"})
Comparator alphabeticalComparator = new Comparator(){
@Override
public int compare(Object o1, Object o2) {
IInvokedMethod m1 = (IInvokedMethod) o1;
IInvokedMethod m2 = (IInvokedMethod) o2;
return m1.getTestMethod().getMethodName().compareTo(m2.getTestMethod().getMethodName());
}
};
Collections.sort((List) invokedMethods, alphabeticalComparator);
}
SimpleDateFormat format = new SimpleDateFormat("yy/MM/dd HH:mm:ss");
boolean addedHeader = false;
for (IInvokedMethod iim : invokedMethods) {
ITestNGMethod tm = iim.getTestMethod();
if (!addedHeader) {
bw.append("
\n");
} catch (IOException e) {
Utils.log("[SuiteHTMLReporter]", 1, "Error writing to " + outputFileName + ": " + e.getMessage());
}
}
/**
* Generate a HTML color based on the class of the method
*/
private String createColor(ITestNGMethod tm) {
// real class can be null if this client is remote (not serializable)
long color = tm.getRealClass() != null ? tm.getRealClass().hashCode() & 0xffffff: 0xffffff;
long[] rgb = {
((color & 0xff0000) >> 16) & 0xff,
((color & 0x00ff00) >> 8) & 0xff,
color & 0xff
};
// Not too dark
for (int i = 0; i < rgb.length; i++) {
if (rgb[i] < 0x60) {
rgb[i] += 0x60;
}
}
long adjustedColor = (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
String result = Long.toHexString(adjustedColor);
return result;
}
private String td(String s) {
StringBuffer result = new StringBuffer();
String prefix = "";
if (s.startsWith(BEFORE)) {
prefix = BEFORE;
}
else if (s.startsWith(AFTER)) {
prefix = AFTER;
}
if (! s.equals(SP)) {
result.append("
");
int open = s.lastIndexOf("(");
int start = s.substring(0, open).lastIndexOf(".");
// int end = s.lastIndexOf(")");
if (start >= 0) {
result.append(prefix + s.substring(start + 1, open));
}
else {
result.append(prefix + s);
}
result.append("
\n");
}
else {
result.append("
").append(SP).append("
");
}
return result.toString();
}
private void ppp(String s) {
System.out.println("[SuiteHTMLReporter] " + s);
}
/**
* Generate information about methods and groups
*/
private void generateMethodsAndGroups(XmlSuite xmlSuite, ISuite suite) {
StringBuffer sb = new StringBuffer();
Map> groups = suite.getMethodsByGroups();
sb.append("
Groups used for this test run
");
if (groups.size() > 0) {
sb.append("
\n")
.append("
Group name
")
.append("
Methods
");
String[] groupNames = groups.keySet().toArray(new String[groups.size()]);
Arrays.sort(groupNames);
for (String group : groupNames) {
Collection methods = groups.get(group);
sb.append("
").append(group).append("
");
StringBuffer methodNames = new StringBuffer();
Map uniqueMethods = Maps.newHashMap();
for (ITestNGMethod tm : methods) {
uniqueMethods.put(tm, tm);
}
for (ITestNGMethod tm : uniqueMethods.values()) {
methodNames.append(tm.toString()).append(" ");
}
sb.append("
" + methodNames.toString() + "
\n");
}
sb.append("
\n");
}
Utils.writeFile(getOutputDirectory(xmlSuite), GROUPS, sb.toString());
}
private void generateIndex(XmlSuite xmlSuite, ISuite sr) {
StringBuffer index = new StringBuffer()
.append("Results for " + sr.getName() + "\n")
.append("\n")
.append("\n")
;
Utils.writeFile(getOutputDirectory(xmlSuite), "index.html", index.toString());
}
private String makeTitle(ISuite suite) {
return "Results for " + suite.getName() + "";
}
private void generateMain(XmlSuite xmlSuite, ISuite sr) {
StringBuffer index = new StringBuffer()
.append("Results for " + sr.getName() + "\n")
.append("Select a result on the left-hand pane.")
.append("\n")
;
Utils.writeFile(getOutputDirectory(xmlSuite), "main.html", index.toString());
}
/**
*
*/
private void generateTableOfContents(XmlSuite xmlSuite, ISuite suite) {
StringBuffer tableOfContents = new StringBuffer();
//
// Generate methods and groups hyperlinks
//
Map suiteResults = suite.getResults();
int groupCount = suite.getMethodsByGroups().size();
int methodCount = 0;
for (ISuiteResult sr : suiteResults.values()) {
ITestNGMethod[] methods = sr.getTestContext().getAllTestMethods();
methodCount += Utils.calculateInvokedMethodCount(methods);
// Collect testClasses
for (ITestNGMethod tm : methods) {
ITestClass tc = tm.getTestClass();
m_classes.put(tc.getRealClass().getName(), tc);
}
}
String name = "Results for " + suite.getName();
tableOfContents
.append("\n")
.append("\n")
.append("" + name + "\n")
.append(HtmlHelper.getCssString())
.append("\n")
;
tableOfContents
.append("\n")
.append("