Hi, If it is too hard to test your private methods via the public interface then it maybe a sign that your class could use a little refactoring and you may want to move code to separate utility/helper classes. Best regards, Mau. 2010/6/8 Rob Riggs <rob@pangalactic.org>:
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 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Mauricio Gomes Pensar Digital 55-11-9698-1683 (Brazil - mobile)