User Tools

Site Tools


tips:java:testprivatemethods

Testing Private Methods

It can be done using the Refletion API:

Method myMethod = MyClass.class.getDeclaredMethod("myMethod", ...);
myMethod.setAccessible(true);
 
myMethod.invoke(...);

For more information, see this tip I wrote

tips/java/testprivatemethods.txt · Last modified: 2009/06/08 12:17 by erik