Art of Unit Testing

Benjamin Niemann pink at odahoda.de
Tue Aug 2 16:27:28 EDT 2005


Christoph Zwerschke wrote:

> Thanks for the link, Grig. I wasn't aware of the py lib so far. The
> possibility to create fixtures at the three different scopes is exactly
> what I was looking for.
> 
> Anyway, I think it would be nice to have that feature in the standard
> lib unittest as well. It should not be too hard to add setUpOnce and
> tearDownOnce methods in addition to setUp and tearDown. Actually, I am
> wondering that there doesn't seem to be any development progress since
> unittest was included in the standard lib of Python 2.1 in August 2001.
> I had expected that such an important module would be continually
> improved and maintained. How come? So few people using unit tests? Or do
> most people write their own testing code or use py.test?

Or because it is already close to perfection (at least in what it is
intended to do).

The unittest module is a 'port' of the JUnit framework for Java which has a
certain wellknown API and semantics. The same API is available for many
other languages, so it is probably a good idea to stick with it in order to
make people coming from other language feel more comfortable with Python.

Some (many?) people don't like the unittest module, because it is not very
pythonic - nothing to wonder as it has its root in the Java world. That's
probably one of the reasons why there are other (more pythonic) unittesting
frameworks for Python out there.

I prefer to use unittest (because this was the API the textbook was using
that introduced me to this topic) and I also had the problem of heavy setup
costs. I deal with it by using a script around my testsuite (instead of
calling just unittest.main()) that does the setup/teardown of the
environment.

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/



More information about the Python-list mailing list