User Tools

Site Tools


tips:java:testprivatemethods

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tips:java:testprivatemethods [2009/06/08 05:17] (current)
erik created
Line 1: Line 1:
 +====== Testing Private Methods ======
  
 +It can be done using the Refletion API:
 +
 +<code java>
 +Method myMethod = MyClass.class.getDeclaredMethod("​myMethod",​ ...);
 +myMethod.setAccessible(true);​
 +
 +myMethod.invoke(...);​
 +</​code>​
 +
 +For more information,​ see this [[http://​erik.thauvin.net/​blog/​news.jsp?​date=2006-01-29#​418|tip]] I wrote
tips/java/testprivatemethods.txt · Last modified: 2009/06/08 05:17 by erik