Boost logo

Boost Users :

From: Kevin Wheatley (hxpro_at_[hidden])
Date: 2006-03-27 15:58:53


Paul Giaccone wrote:
>
> Ryo IGARASHI wrote:
>
> >On 3/23/06, Leif Gruenwoldt <leifer_at_[hidden]> wrote:
> >
> >
> >>Is there a way to test the private functions of a class without moving
> >>them into public scope during test?
> >>
> >>What are some strategies for this?

use protected, then Subclass and override,

use friend classes

use link seams (See Michael Feather's Working Effectively with legacy
code)

They all involve some kind of uglyness. In the real world some people
ask the question if its private then why are you testing it, on the
grounds that anything complicated enough to demand tests, is
suggestive of a desire for that functionality to be extracted into its
own class/function, which then becomes a public interface on the
previously private calls and thus becomes testable.

Kevin

-- 
| Kevin Wheatley, Cinesite (Europe) Ltd | Nobody thinks this      |
| Senior Technology                     | My employer for certain |
| And Network Systems Architect         | Not even myself         |

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