[Haskell-cafe] HSpec vs Doctest for TDD
Alois Cochard
alois.cochard at gmail.com
Fri Jun 27 08:55:33 UTC 2014
On 27 June 2014 00:22, Richard A. O'Keefe <ok at cs.otago.ac.nz> wrote:
>
> For one thing, tests can be automatically generated from a grammar.
> The first time I demonstrated this to a class of students, I said
> "now, here I've got this program that I wrote a few years ago and
> I know it works, this is just demonstrating how you can generate
> tests from a grammar." And then the very first generated test
> revealed a bug. At that point I was Enlightened.
>
>
Sure that is awesome, same kind of thing as using QuickCheck in a way...
but do you consider this as TDD?
I always seen TDD as "writing test first", where here you generate them
once you have the grammar... that feel different to me, but as said before
I'm realizing my definition was wrong.
> But the most important thing here is that a grammar and an API
> are not that different.
Yeah I completely agree, the fact that I was trying to make a point
specific to DSL design is wrong... it's should be the same really.
> The whole *point* of writing your tests
> first is that the interfaces we design are just another of the
> things we get wrong.
>
But don't you think this particular step can be achieved in your head?
Maybe not for complex thing, but at least it work for me for simple case...
I test the interface in my head or on paper before actually coding them
(I'm not saying *implementing* them!)
> Don't mistake me. I am *not* good at testing yet. The only
> reason I'm defending TDD is that I have after too many years
> finally learned that "if it isn't tested it doesn't work" is
> true of *MY* code, so the earlier I test something the less
> horribly embarrassed I'm going to be.
>
>
That's for sure, but that point is imo about testing in general and not TDD
in particular.
Once you deliver a piece of work, it should be proven it work... Maybe
doing it earlier help, but that's more about fighting procrastination than
anything else, because I'm sure you hate as much as me writing tests ;-)
> We are not called to be right.
> We are called to improve.
> Learn from many masters but obey none.
>
>
Nice, a wise advice that I'll surely remember.
--
*A\ois*
http://twitter.com/aloiscochard
http://github.com/aloiscochard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140627/5f679229/attachment-0001.html>
More information about the Haskell-Cafe
mailing list