|
Boost Users : |
Subject: Re: [Boost-users] Testing private methods in Boost
From: Rob Riggs (rob_at_[hidden])
Date: 2010-06-08 21:03:23
On 06/08/2010 01:54 PM, hmiller_at_[hidden] 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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net