[TIP] Doctest or unitest?
grig at gheorghiu.net
Sat Mar 3 09:29:18 PST 2007
This is the question that Michael Foord asks in his latest blog post:
To me, they represent 2 different styles of testing: procedural
(unittest) vs. declarative (doctest). I had an aha-type moment during
PyCon when I realized that both Fit/Fitnesse and doctest are very
similar in that they represent 'example-driven testing' (I didn't
invent the term example-driven, Brian Marick did). You specify inputs
with expected outputs, in the form of examples.
With unittest, and the other frameworks based on it or similar to it,
there's more procedural stuff: do this, do that, then assert that it
happened (FitNesse also supports this with DoFixture fixtures).
I find both styles useful. The other value of Fit/Fitnesse and doctest
is that they serve as 'executable documentation'.
More information about the testing-in-python