commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S├ębastien Brisard <>
Subject Re: [math] Checking preconditions on package private functions
Date Fri, 30 Nov 2012 06:59:15 GMT

2012/11/27 Gilles Sadowski <>

> Hello.
> > > [...]
> > Actually, I would like the methods to be tested, so they cannot be
> > private. That's the reason why I made them package private.
> You can indirectly test them by passing appropriate arguments to the public
> methods that use them. Please do not select a visibility scope just for the
> sake of unit testing.
> Yes, I know that it is bad practice, and also testing public method allows
indirect testing of the private methods. However, the branching between the
public method (namely Beta.logBeta) and  all private methods is quite
intricate. In order to make sure that the testing of the private methods is
comprehensive, I would be much in favor of direct testing of these private
methods. In fact, there is a way out: reflection indeed permits access to
private methods.

Does anyone oppose the usage of reflection in unit testing to access
private methods?
I personnally think it is a good compromise between encapsulation and
comprehensive testing.

Best regards,

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message