[Tutor] Do you use unit testing?

Serdar Tumgoren zstumgoren at gmail.com
Mon Nov 16 23:22:43 CET 2009


> I learned TDD with PyUnit, but since moved to using Ruby, and have
> been spoilt by rspec and even cucumber.  My instincts are to write
> things test first, but so far I'm not finding PyUnit easy enough to
> get going.
>

The Dive Into Python chapter walks the process of writing/thinking
through "requirements" as a precursor to writing tests.

http://diveintopython.org/unit_testing/index.html

These aren't high-level abstract requirements per se, but lower-level
requirements based on observations about how a function, method or
class should work. In the Roman numerals example it uses, here's one
of the requirements:

    "There is no way to represent negative numbers in Roman numerals."

Based on those observations, he codes up the unit tests, and then
finally the actual functions and methods.

That approach makes sense, but again, it's always tougher when you're
working on your own project....


More information about the Tutor mailing list