/** @return TestCase.getName() or Test.toString() or "nullTest" */ public static String safeTestName(Test test) { if (test instanceof TestCase) { return ((TestCase) test).getName(); } else if (null != test) { return test.toString(); } else { return "nullTest"; } }
protected static String getMethodName(Test test) { String className; String desc = test.toString(); Matcher matcher = methodpattern.matcher(desc); if (matcher.matches()) { className = matcher.group(1); } else { className = desc; } return className; }
public void addFailure(Test test, AssertionFailedError t) { StringBuffer sb = new StringBuffer(); sb.append(test.toString()); sb.append("\n"); StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw, true)); sb.append(sw.toString()); Log.getLogWriter().severe("zzzzzFAILURE IN " + test, t); // reportFailure(test, sb.toString()); lastFailClass = getClassName(test); lastFailMethod = getMethodName(test); lastThrowable = t; }
public void startTest(Test test) { this.startTime = System.currentTimeMillis(); String s = "zzzzzSTART " + test; Log.getLogWriter().info(s); testInProgress = test.toString(); }