Re: Dos and don'ts in C++ unit testing?
In article <roy-F68511.11180218022007@032-325-625.area1.spcsdns.net>,
Roy Smith <roy@panix.com> wrote:
Francis Glassborow wrote:
I generally write a member function then test it before I progress to
writing the next one.
Gennaro Prota <clcppm-poster@this.is.invalid> wrote:
Hmm, I had a look at my code base, and there are a lot of places where
that would have not been possible (as I was expecting): very often one
of the member functions require other member functions to work
(sometimes private member function, but even public ones). Would you
consider that a sign of (possibly) bad design or implementation?
There are certainly lots of times where one public method calls another,
but the call graph is usually a tree (or at least, a DAG). If that's the
case, just write (and test) the leaf methods first. Of course, this
assumes you know enough about how the class will end up when you start
writing it to know what the call graph will be :-)
I remember reading once in some old C programming book, "design from the
top down, implement from the bottom up." (I think the title was
something like "Graphics in C")
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]