commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luc Maisonobe <>
Subject Re: [math] Using reflection to test private methods
Date Fri, 30 Nov 2012 11:43:21 GMT
Le 30/11/2012 09:19, Thomas Neidhart a écrit :
> On Fri, Nov 30, 2012 at 8:06 AM, Sébastien Brisard <
>> wrote:
>> Hi,
>> I've already posted the same question in another thread [1], but I thought
>> having a dedicated thread would increase its visibility.
>> Here is my problem. The new implementation of Beta.logBeta(double, double)
>> I'm currently working on relies on several private methods through a rather
>> complex branching.
>> Due to this complicated branching, I find it much safer to have direct
>> tests for these private methods, instead of relying on the tests of
>> Beta.logBeta to validate these methods.
>> Therefore, in order to preserve encapsulation (these private methods should
>> really remain private, and not package private, as I previously did [2]), I
>> propose to use reflection in the unit tests to access these private
>> methods. I've tested this option locally, it seems to me that it is a
>> viable option.
>> What do you think about this compromise?
> imho, this is perfectly valid in such a specific case, and I had to do the
> same in other projects occasionally.

+1, and I used the same trick already in some projects.


> Thomas

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message