|
Boost Users : |
Subject: Re: [Boost-users] whitebox testing with boost unit test framework?
From: Olaf Meeuwissen (olaf.meeuwissen_at_[hidden])
Date: 2011-12-21 18:36:54
Chris Cleeland <chris.cleeland_at_[hidden]> writes:
> I'm using the boost unit test framework to implement unit tests for
> code. I'm wondering if there is a best-practice for doing white-box
> testing/internal state inspection of types under test. My hack right
> now is to strip out "protected" and "private" from the header, but I
> hold my nose as I do that.
I don't use private members in the header file and put a subclass in the
test implementation that makes the parent class' protected API public.
So you get, in the header, something like:
class A {
public:
//
protected:
int i;
};
and then in the test implementation file
#include "A.hpp"
class A_test : A {
public:
using i;
};
so that in the tests you can access i without any problem.
Hope this helps,
-- Olaf Meeuwissen, LPIC-2 FLOSS Engineer -- AVASYS CORPORATION FSF Associate Member #1962 Help support software freedom http://www.fsf.org/jf?referrer=1962
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