In Method: | init(IClass, Object, ITestNGMethod, Throwable, long, long, ITestContext) |
Code with Finding: |
class TestResult {
/**
*
* @param testClass
* @param instance
* @param method
* @param throwable
* @param start
* @param end
*/
public void init (IClass testClass,
Object instance,
ITestNGMethod method,
Throwable throwable,
long start,
long end,
ITestContext context)
{
m_testClass = testClass;
m_throwable = throwable;
m_instanceName = m_testClass.getName();
if (null == m_throwable) {
m_status = ITestResult.SUCCESS;
}
m_startMillis = start;
m_endMillis = end;
m_method = method;
m_context = context;
m_instance = instance;
// Calculate the name: either the method name, ITest#getTestName or
// toString() if it's been overridden.
if (m_instance == null) {
m_name = m_method.getMethodName();
} else {
if (m_instance instanceof ITest) {
m_name = ((ITest) m_instance).getTestName();
}
else if (testClass.getTestName() != null) {
m_name = testClass.getTestName();
}
else {
String string = m_instance.toString();
// Only display toString() if it's been overridden by the user
m_name = getMethod().getMethodName();
try {
if (!Object.class.getMethod("toString")
.equals(m_instance.getClass().getMethod("toString"))) {
m_instanceName = string.startsWith("class ")
? string.substring("class ".length())
: string;
m_name = m_name + " on " + m_instanceName;
}
}
catch(NoSuchMethodException ignore) {
// ignore
}
}
}
}
}
|