[TIP] testing class properties and internal methods

Nate Lowrie solodex2151 at gmail.com
Mon Mar 5 14:26:21 PST 2007


On 3/5/07, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> Nate Lowrie wrote:
> > Just wondering what the thoughts were on this.....
> >
> > I have never tested class properties since they are basically getter
> > and setter functions.  I also never test getter and setter functions
> > either.
> >
> > Also, I have not taken to writing unit tests for the "private",
> > internal methods not in the public interface for a class.  I do this
> > since they are called from the public interface methods.
> >
> > What are people's thoughts on this?
> >
> >
> Where private methods (not part of the public API) provide a unit of
> functionality, we unit test them.
>
> We like to specify code behaviour in our test names (similar to some of
> the BDD stuff I think, but I haven't had a chance to read much on this
> yet). Specifying behaviour for the code only through the public API can
> lead to some very complex tests / specifications.
>
> It is often easier to specify public API behaviour in terms of calling
> down to private methods - and then mock out these private methods in the
> test of the public API. The private methods can then be tested separately.

Do you test python properties at all?

>
> All the best,
>
>
> Fuzzyman
> http://www.voidspace.org.uk/python/articles.shtml
>
>
> > Cheers,
> >
> > Nate L.
> >
> > _______________________________________________
> > testing-in-python mailing list
> > testing-in-python at lists.idyll.org
> > http://lists.idyll.org/listinfo/testing-in-python
> >
> >
>
>



More information about the testing-in-python mailing list