[Haskell-beginners] testing and the culture of Haskell

Amy de Buitléir amy at nualeargais.ie
Wed Jan 20 05:31:16 EST 2010


I'm pretty new to Haskell, so take what I say with a very large grain
of salt. But this is a topic I've been thinking about because I happen
to be teaching a lab on TDD to Java and C developers at the moment,
while I myself am programming in Haskell in my research. So perhaps my
impressions will be of some use to you.

There are two reasons why I'm less likely to do TDD in Haskell. By far
the most important is the availability of a tool like QuickCheck.
QuickCheck changes everything. I don't write tests, I write
properties. QuickCheck generates the tests on the fly, and does a
better job than I could. There's a big difference between writing
properties and writing tests. If I were going to develop a large
application in Haskell, I'd try to honour the spirit of TDD by
defining properties before implementing functions.

A secondary reason is the availability of the interpreter. I test
functions in the interpreter as I write them. Of course, I'm not doing
a very thorough job, but I'll use QuickCheck to do the "real" testing.
I use the interpreter to test whether the function does what I
designed it to do, with some typical inputs. I then use QuickCheck to
verify that the function behaves nicely no matter what inputs it gets,
including inputs I might not have even thought of trying.

FWIW, I do plan to use HUnit to test the non-functional part of my application.


More information about the Beginners mailing list