On his Bliki (a kind of combination blog and wiki), Martin Fowler has updated an old post of his that talks about Specification By Example.
While the idea has been around for a long time, it seems to suffer from the cycles of fashion.
On the one hand you have those who point out (rightly) that Examples can never capture all the required behaviour - and that it’s possible to spoof any automated tests based on those examples by hard coding the relevant answers.
On the other hand you have those who respond (also rightly) that writing complete and correct Pre- and Post-conditions is often too hard (as hard or harder than writing the actual code), and that using Examples is good enough for many cases.
What’s my position? In my usual middle of the road fashion, I think they’re both right.
In fact, I’ve recently been championing Fit by Ward Cunningham (and friends) as a way to introduce some automated testing into our process. The most natural way to use Fit is by using Specification By Example - ensuring the code produced the expected answers to a standard set of examples.
I don’t think that widespread use of Fit can replace all testing on our projects - but I do believe that it can provide a very large measure of value.
Comments
blog comments powered by Disqus