
9 Jun
2010
9 Jun
'10
4:02 a.m.
On Tue, Jun 8, 2010 at 3:54 PM,
Is their a good strategy for testing private methods in a class using Boost? I am looking for something that is non-intrusive to the developed code, but I can't think of any good ways without modifying the code under test. Thanks, Herb Miller
Either add a public function 'internal_test()' to the class, and have it run the tests, or add a friend class. Yes both of these are a bit intrusive. Adding a friend class is really bad as it breaks the encapsulation. Having a public function that does internal testing doesn't sound too bad to me. Keeps the encapsulation, allows tests to be close to the code it is testing. Tony