[Haskell-cafe] HSpec vs Doctest for TDD
Erik de Castro Lopo
mle+hs at mega-nerd.com
Sat Jun 28 09:14:47 UTC 2014
Gautier DI FOLCO wrote:
> Hi all,
>
> I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such
> as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not
> idiomatic in Haskell.
> I have a bunch of questions:
> - Do you do TDD?
> - Which tools do you use?
> - Is doctest "better" (in some senses) than HSpec? Why?
> - Are HSpec and Doctest complementary? If so, in which case do you use one
> or another?
> - Is there some Haskell-specific good practices do to TDD?
In languages other than Haskell I do sometimes write tests first
and practive real TDD.
I Haskell writing test first seems a little ridculous. What I tend to
do is:
* Write the types.
* Make sure the types interact together.
* Fill in the functions.
* For stuff that cannot be enforced by types, write tests.
For tests I use Hspec (both canned example test and QuickCheck style
property tests) but intend to start suplementing it with doctest so
that example code in the docstring comments is tested for correctness.
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
More information about the Haskell-Cafe
mailing list