[Haskell-cafe] Type System vs Test Driven Development

Gregory Collins greg at gregorycollins.net
Wed Jan 5 22:27:29 CET 2011


On Wed, Jan 5, 2011 at 9:02 PM, Jonathan Geddes
<geddes.jonathan at gmail.com> wrote:

> Despite all this, I suspect that since Haskell is at a higher level of
> abstraction than other languages, the tests in Haskell must be at a
> correspondingly higher level than the tests in other languages. I can
> see that such tests would give great benefits to the development
> process. I am convinced that I should try to write such tests. But I
> still think that Haskell makes a huge class of tests unnecessary.

The testing stuff available in Haskell is top-notch, as others have
pointed out. One of the biggest PITAs with testing in other languages
is having to come up with a set of test cases to fully exercise your
code. If you don't keep code coverage at 100% or close to it, it is
quite easy to test only the inputs you are *expecting* to see (because
programmers are lazy) and end up with something which is quite broken
or even insecure w.r.t. buffer overruns, etc. (Of course we don't
usually have those in Haskell either.)

QuickCheck especially is great because it automates this tedious work:
it fuzzes out the input for you and you get to think in terms of
higher-level invariants when testing your code. Since about six months
ago with the introduction of JUnit XML support in test-framework, we
also have plug-in instrumentation support with continuous integration
tools like Hudson:

  http://buildbot.snapframework.com/job/snap-core/
  http://buildbot.snapframework.com/job/snap-server/

It's also not difficult to set up automated code coverage reports:

  http://buildbot.snapframework.com/job/snap-core/HPC_Test_Coverage_Report/
  http://buildbot.snapframework.com/job/snap-server/HPC_Test_Coverage_Report/

Once I had written the test harness, I spent literally less than a
half-hour setting this up. Highly recommended, even if it is a (blech)
Java program. Testing is one of the few areas where I think our
"software engineering" tooling is on par with or exceeds that which is
available in other languages.

G
-- 
Gregory Collins <greg at gregorycollins.net>



More information about the Haskell-Cafe mailing list