Search

Google

Sunday, August 19, 2007

Testing Private Methods



It is possible to call Private method of a class using the Refletion API:


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

myMethod.invoke(...);


Above snippet of code can be used to call private method, of a class

No comments: