本文整理了Java中org.testng.internal.Utils.toString()
方法的一些代码示例,展示了Utils.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.toString()
方法的具体详情如下:
包路径:org.testng.internal.Utils
类名称:Utils
方法名:toString
[英]Returns the string representation of the specified object, transparently handling null references and arrays.
[中]返回指定对象的字符串表示形式,透明地处理空引用和数组。
代码示例来源:origin: org.testng/testng
public static void checkReturnType(Method method, Class<?>... returnTypes) {
if (method == null) {
return;
}
for (Class<?> returnType : returnTypes) {
if (method.getReturnType() == returnType) {
return;
}
}
throw new TestNGException(method.getDeclaringClass().getName() + "."
+ method.getName() + " MUST return " + toString(returnTypes) + " but returns " + method.getReturnType().getName());
}
代码示例来源:origin: org.testng/testng
public static String getTestResultName(ITestResult tr) {
StringBuilder result = new StringBuilder(tr.getMethod().getMethodName());
Object[] parameters = tr.getParameters();
if (parameters.length > 0) {
result.append("(");
StringBuilder p = new StringBuilder();
for (int i = 0; i < parameters.length; i++) {
if (i > 0) p.append(", ");
p.append(Utils.toString(parameters[i]));
}
if (p.length() > 100) {
String s = p.toString().substring(0, 100);
s = s + "...";
result.append(s);
} else {
result.append(p.toString());
}
result.append(")");
}
return result.toString();
}
代码示例来源:origin: cbeust/testng
private boolean dumpParametersInfo(String prefix, Object[] parameters) {
int parameterCount = (parameters == null ? 0 : parameters.length);
if (parameterCount == 0) {
return false;
}
writer.print("<tr class=\"param\">");
for (int i = 1; i <= parameterCount; i++) {
writer.print(String.format("<th>%s #", prefix));
writer.print(i);
writer.print("</th>");
}
writer.print("</tr><tr class=\"param stripe\">");
for (Object parameter : parameters) {
writer.print("<td>");
writer.print(Utils.escapeHtml(Utils.toString(parameter)));
writer.print("</td>");
}
writer.print("</tr>");
return true;
}
代码示例来源:origin: cbeust/testng
public static void checkReturnType(Method method, Class<?>... returnTypes) {
if (method == null) {
return;
}
for (Class<?> returnType : returnTypes) {
if (method.getReturnType() == returnType) {
return;
}
}
throw new TestNGException(
method.getDeclaringClass().getName()
+ "."
+ method.getName()
+ " MUST return "
+ toString(returnTypes)
+ " but returns "
+ method.getReturnType().getName());
}
代码示例来源:origin: org.testng/testng
msg.append(", ");
msg.append(Utils.toString(params[i], paramTypes[i]));
代码示例来源:origin: cbeust/testng
public static String getTestResultName(ITestResult tr) {
StringBuilder result = new StringBuilder(tr.getMethod().getMethodName());
Object[] parameters = tr.getParameters();
if (parameters.length > 0) {
result.append("(");
StringBuilder p = new StringBuilder();
for (int i = 0; i < parameters.length; i++) {
if (i > 0) p.append(", ");
p.append(Utils.toString(parameters[i]));
}
if (p.length() > 100) {
String s = p.toString().substring(0, 100);
s = s + "...";
result.append(s);
} else {
result.append(p.toString());
}
result.append(")");
}
return result.toString();
}
代码示例来源:origin: cbeust/testng
msg.append(", ");
msg.append(Utils.toString(params[i], paramTypes[i]));
代码示例来源:origin: org.testng/testng
for (Object parameter : parameters) {
writer.print("<td>");
writer.print(Utils.escapeHtml(Utils.toString(parameter)));
writer.print("</td>");
代码示例来源:origin: org.testng/testng
m_out.print("<tr class=\"param stripe\">");
for (Object p : parameters) {
m_out.println("<td>" + Utils.escapeHtml(Utils.toString(p)) + "</td>");
代码示例来源:origin: org.testng/testng
sb.append(", ");
sb.append(Utils.toString(params[i], paramTypes[i]));
代码示例来源:origin: cbeust/testng
m_out.print("<tr class=\"param stripe\">");
for (Object p : parameters) {
m_out.println("<td>" + Utils.escapeHtml(Utils.toString(p)) + "</td>");
代码示例来源:origin: org.testng/testng
private void generateMethod(String tagClass, ITestResult tr,
ITestContext context, XMLStringBuffer xsb) {
long time = tr.getEndMillis() - tr.getStartMillis();
xsb.push(D, C, "method");
xsb.push(D, C, "method-content");
xsb.addOptional(S, tr.getMethod().getMethodName(), C, "method-name");
// Parameters?
if (tr.getParameters().length > 0) {
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object p : tr.getParameters()) {
if (!first) sb.append(", ");
first = false;
sb.append(Utils.toString(p));
}
xsb.addOptional(S, "(" + sb.toString() + ")", C, "parameters");
}
// Exception?
if (tr.getThrowable() != null) {
StringBuilder stackTrace = new StringBuilder();
for (StackTraceElement str : tr.getThrowable().getStackTrace()) {
stackTrace.append(str.toString()).append("<br>");
}
xsb.addOptional(D, stackTrace.toString() + "\n",
C, "stack-trace");
}
xsb.addOptional(S, " " + Long.toString(time) + " ms", C, "method-time");
xsb.pop(D);
xsb.pop(D);
}
代码示例来源:origin: cbeust/testng
sb.append(", ");
sb.append(Utils.toString(params[i], paramTypes[i]));
代码示例来源:origin: org.testng/testng
if (!first) sb.append(", ");
first = false;
sb.append(Utils.toString(p));
代码示例来源:origin: cbeust/testng
if (!first) sb.append(", ");
first = false;
sb.append(Utils.toString(p));
代码示例来源:origin: io.brooklyn/brooklyn-utils-test-support
sb.append(", ");
sb.append(Utils.toString(params[i], paramTypes[i]));
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-test-support
sb.append(", ");
sb.append(Utils.toString(params[i], paramTypes[i]));
内容来源于网络,如有侵权,请联系作者删除!