|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.commons.test.PrivateTestCase
A test case with utility methods used to access private members and test private methods. Bill Venners discusses the technique of unit testing private code without basturdizing your code in the following artical: Testing Private Methods with JUnit and SuiteRunner. We have created this class to follow his recommendation for unit testing private methods using Reflection.
Constructor Summary | |
PrivateTestCase()
|
|
PrivateTestCase(java.lang.String s)
|
Method Summary | |
static java.lang.Object |
getMember(java.lang.String name,
java.lang.Object obj)
Gets a member regardless of its visibility. |
static java.lang.Object |
invoke(java.lang.Class targetClass,
java.lang.String methodName,
java.lang.Class[] argClasses,
java.lang.Object[] argObjects)
Invokes a static method on a class regardless of the method's visibility. |
static java.lang.Object |
invoke(java.lang.Object obj,
java.lang.Class targetClass,
java.lang.String methodName,
java.lang.Class[] argClasses,
java.lang.Object[] argObjects)
Invokes a method on an object regardless of the method's visibility. |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString |
Methods inherited from class junit.framework.Assert |
assertEquals, 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, fail, fail, failNotEquals, failNotSame, failSame |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public PrivateTestCase()
public PrivateTestCase(java.lang.String s)
Method Detail |
public static java.lang.Object getMember(java.lang.String name, java.lang.Object obj)
name
- the name of the memberobj
- the Object whose member we access
public static java.lang.Object invoke(java.lang.Object obj, java.lang.Class targetClass, java.lang.String methodName, java.lang.Class[] argClasses, java.lang.Object[] argObjects)
obj
- the object whose method is calledtargetClass
- the class of the object (don't need it)methodName
- the name of the method to invokeargClasses
- the classes of the argsargObjects
- the arguments of the call
public static java.lang.Object invoke(java.lang.Class targetClass, java.lang.String methodName, java.lang.Class[] argClasses, java.lang.Object[] argObjects)
targetClass
- the class of the object (don't need it)methodName
- the name of the method to invokeargClasses
- the classes of the argsargObjects
- the arguments of the call
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |