
9 Jun
2010
9 Jun
'10
1:03 a.m.
On 06/08/2010 01:54 PM, hmiller@hiwaay.net wrote:
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.
#define private public #define protected public #include "MyClass.hpp" #undef protected #undef private That's the horribly wrong answer. The right answer is "don't test privates except through the public interface". Testing private methods explicitly will result in classes that are hard to refactor because the unit tests, upon which one relies heavily during any refactoring exercise, constrain the implementation. Regards, Rob