Methods Summary |
---|
public int | countTestCases()Counts the number of test cases executed by run(TestResult result).
return 1;
|
protected junit.framework.TestResult | createResult()Creates a default TestResult object
return new TestResult();
|
public java.lang.String | getName()Gets the name of a TestCase
return fName;
|
public junit.framework.TestResult | run()A convenience method to run this test, collecting the results with a
default TestResult object.
TestResult result= createResult();
run(result);
return result;
|
public void | run(junit.framework.TestResult result)Runs the test case and collects the results in TestResult.
result.run(this);
|
public void | runBare()Runs the bare test sequence.
setUp();
try {
runTest();
}
finally {
tearDown();
}
|
protected void | runTest()Override to run the test and assert its state.
assertNotNull(fName);
Method runMethod= null;
try {
// use getMethod to get all public inherited
// methods. getDeclaredMethods returns all
// methods of this class but excludes the
// inherited ones.
runMethod= getClass().getMethod(fName, (Class[]) null);
} catch (NoSuchMethodException e) {
fail("Method \""+fName+"\" not found");
}
if (!Modifier.isPublic(runMethod.getModifiers())) {
fail("Method \""+fName+"\" should be public");
}
try {
runMethod.invoke(this, (Object[]) new Class[0]);
}
catch (InvocationTargetException e) {
e.fillInStackTrace();
throw e.getTargetException();
}
catch (IllegalAccessException e) {
e.fillInStackTrace();
throw e;
}
|
public void | setName(java.lang.String name)Sets the name of a TestCase
fName= name;
|
protected void | setUp()Sets up the fixture, for example, open a network connection.
This method is called before a test is executed.
|
protected void | tearDown()Tears down the fixture, for example, close a network connection.
This method is called after a test is executed.
|
public java.lang.String | toString()Returns a string representation of the test case
return getName() + "(" + getClass().getName() + ")";
|