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
Next Post
What makes a Professional Developer?  25 Jun 2006
Prior Post
Coding Paradigms  03 Jun 2006
Related Posts
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
Archives
June 2006
2006