
On 25 May 2010 13:36, Ionut G. Stan
I'm doing TDD in pretty much all of the languages that I know, and I want to introduce it early in my Haskell learning process. I wonder though, if there's some established process regarding TDD, not unit testing.
I've heard of QuickCheck and HUnit, but I've also read that QuickCheck is used mostly for testing pure code, while HUnit for impure code?
What framework lends itself better for writing tests before the actual production code? Can you point out to some resources regarding this?
Real World Haskell has a chapter dedicated to writing Tests for your code using QuickCheck[1]. The writers of this book work in industries where well tested programs are essential. Personally I suppose I follow a methodology of type driven development followed by tests. I wrote a simple Emacs library to make testing QuickCheck properties easier[2]. It's convenient because it lets you check a function when your cursor is at the definition, or test all properties in the current file. It picks up properties by symbols named foo_prop, where foo is the function that the foo_prop property is written for. Maybe this workflow suites your needs.
Oh, and a small off-topic question? Is it considered a good practice to use implicit imports in Haskell? I'm trying to learn from existing packages, but all those "import all" statements drive me crazy.
I would follow tibbe's Haskell style guide[3] because it is strict and reasonable. To quote it on this topic: "Always use explicit import lists or qualified imports for standard and third party libraries. This makes the code more robust against changes in these libraries. Exception: The Prelude." [1]: http://book.realworldhaskell.org/read/testing-and-quality-assurance.html [2]: http://www.emacswiki.org/emacs-en/QuickCheckHaskell [3]: http://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md