Boost Users :
Subject: Re: [Boost-users] Testing private methods in Boost
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2010-06-09 00:02:28
On Tue, Jun 8, 2010 at 3: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.
> 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.
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