junit.framework.Testclass TestWithCustomTest
extends junit.framework.TestCase
Each user-provided test is allowed to return a Boolean, either a primitive or a java.lang.Boolean -- it does not matter. If the user-provided test returns a Boolean and it is false, then the test is considered to have failed. If the user-provided test throws or returns a Throwable, it is considered to have failed. If the user-provided test returns anything else (including void) then the test is considered to have passed.
Note: Returning Throwable is a little bit cleaner than throwing an Exception, but either is acceptable as a sign of test failure. This is because when a Throwable is returned, if -printStack is in effect, then the CORRECT stack trace can be displayed and not a stack dump from the refective invocation.
There is no requirement that the user-provided test implement any interface, nor any requirement that the user-provided test return anything at all. However, a test that returns "void" and that never throws an Exception is not a very useful test as it can never fail.
| Modifier and Type | Field | Description |
|---|---|---|
protected FailureType |
_failure |
The failure object that is not null is the test intends to fail.
|
protected boolean |
_failureExpected |
True if the test is supposed to return failure or throw an Exception.
|
| Constructor | Description |
|---|---|
TestWithCustomTest(java.lang.String name) |
Blank constructor for this test case.
|
TestWithCustomTest(java.lang.String name,
XMLTestCase tc) |
Constructs a test case that when invoked will delegate to the provided
test case.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected java.lang.Object |
getTestObject(java.lang.String testClassName) |
Gets an instance of our test object, as configured.
|
void |
runTest() |
Runs our test case using our delegate object where necessary.
|
protected void |
setUp() |
Provides setup for our delegated test case, depending on the type of
test case we are delegating for.
|
protected void |
tearDown() |
Provides tear down for our delegated test case, depending on the type of
test case we are delegating for.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitassertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, setName, toStringprotected final FailureType _failure
protected final boolean _failureExpected
TestWithCustomTest(java.lang.String name)
name - Name of our delegate test caseTestWithCustomTest(java.lang.String name,
XMLTestCase tc)
name - Name of our delegate test casetc - protected void setUp()
throws java.lang.Exception
setUp in class junit.framework.TestCasejava.lang.Exception - if anything goes wrong during setupprotected void tearDown()
throws java.lang.Exception
tearDown in class junit.framework.TestCasejava.lang.Exception - if anything goes wrong during teardownpublic void runTest()
runTest in class junit.framework.TestCasejava.lang.Exception - when anything goes wrong (this is temporary)protected java.lang.Object getTestObject(java.lang.String testClassName)
throws java.lang.ClassNotFoundException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
testClassName - name of the test classjava.lang.ClassNotFoundException - when the test object's class cannot be foundjava.lang.IllegalAccessException - when the test object's constructor is private or protectedjava.lang.InstantiationException - when the test object is abstract or an interfaceIntalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com