Methods Summary |
---|
public junit.framework.TestCase | createTest()
return instantiateTest(enclosingClass, testMethodName);
|
public boolean | equals(java.lang.Object o)
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TestMethod that = (TestMethod) o;
if (enclosingClassname != null
? !enclosingClassname.equals(that.enclosingClassname)
: that.enclosingClassname != null) {
return false;
}
if (testMethodName != null
? !testMethodName.equals(that.testMethodName)
: that.testMethodName != null) {
return false;
}
return true;
|
public T | getAnnotation(java.lang.Class annotationClass)
try {
return getEnclosingClass().getMethod(getName()).getAnnotation(annotationClass);
} catch (NoSuchMethodException e) {
return null;
}
|
public java.lang.Class | getEnclosingClass()
return enclosingClass;
|
public java.lang.String | getEnclosingClassname()
return enclosingClassname;
|
public java.lang.String | getName()
return testMethodName;
|
public int | hashCode()
int result;
result = (enclosingClassname != null ? enclosingClassname.hashCode() : 0);
result = 31 * result + (testMethodName != null ? testMethodName.hashCode() : 0);
return result;
|
private junit.framework.TestCase | instantiateTest(java.lang.Class testCaseClass, java.lang.String testName)
Constructor[] constructors = testCaseClass.getConstructors();
if (constructors.length == 0) {
return instantiateTest(testCaseClass.getSuperclass(), testName);
} else {
for (Constructor constructor : constructors) {
Class[] params = constructor.getParameterTypes();
if (noargsConstructor(params)) {
TestCase test = ((Constructor<? extends TestCase>) constructor).newInstance();
// JUnit will run just the one test if you call
// {@link TestCase#setName(String)}
test.setName(testName);
return test;
} else if (singleStringConstructor(params)) {
return ((Constructor<? extends TestCase>) constructor)
.newInstance(testName);
}
}
}
throw new RuntimeException("Unable to locate a constructor for "
+ testCaseClass.getName());
|
private boolean | noargsConstructor(java.lang.Class[] params)
return params.length == 0;
|
private boolean | singleStringConstructor(java.lang.Class[] params)
return (params.length == 1) && (params[0].equals(String.class));
|
public java.lang.String | toString()
return enclosingClassname + "." + testMethodName;
|