Behavior Driven Development: As Human As Possible
I've been intrigued with everything I've read about "Behavior Driven Development" -- which is essentially a friendlier face on Test Driven Development.
For beginners like me I think the most obvious concept is that BDD = Test Driven Development Plus "natural sentence style test naming" as JP Boodhoo calls it.
For example, David Laribee gives examples where Tests and test fixtures are simply renamed according to a strict pattern, like this:
public class When_an_election_is_started : Spec
private ITransaction _stubTransaction;
private TransactionElection _election;
public void The_result_should_be_in_progress()
The upshot of this is that the tests in the code runner read like a restricted-subset of plain English:
Some people, including David Laribee and Ryan LaNeve have said that the output of these stories could be improved to present a more human-readable form.
What i'd like to see is a better looking code runner.
The treeview control itself should present a "Friendlier" form of those names -- underscores could be converted into spaces. Larger fonts could be used for sub-headings. And the larger headings should be in lower contrast colour, so you can fade them out when you want to.
Here's a dodgy mockup:
Specifications for Transaction Election When votes are cast: A single no vote should rollback the transaction. A no vote will leave the election with a finished and voted no status. Unanimous yes votes will commit the underlying transaction.
The point here is that I'm not talking about improving the output of the unit test tool -- for example the 'Dox report generated by the MbUnit GUI runner' (as Ryan LaNeve has demonstrated)-- I'm talking about changing the runner itself so that it directly cleans up the names of the tests and fixtures for presentation.
It could even report on "Convention Breakers". (Squiggly red underline perhaps).
(side note: matt calla provides a macro for doing the exact opposite of this.)
(Other side note: is this similar to Donald Knuth's idea of literate programming?)
'Ben' on Tue, 13 May 2008 16:19:41 GMT, sez:
Not another "<enter-word-here> Driven Development" scheme!!
Ok, that is cool though.... :)
'Arjan Zuidhof' on Tue, 13 May 2008 18:09:17 GMT, sez:
The idea of BDD seems nice, but it can't ever be literate programming, as everything invented by the K-nuth is impossible to understand for us mere mortals.
And by inspecting the wikipedia page http://en.wikipedia.org/wiki/Literate_programming it seems that is indeed stretched a bit further that just creating a userfriendly name for our methods
'OJ' on Tue, 13 May 2008 19:53:09 GMT, sez:
Leon, I think you've left one of your sentences hanging:
"Some people, including David and Ryan LaNeve have said that these stories"
Not sure if you intended to leave it like this ;)
'lb' on Wed, 14 May 2008 08:13:37 GMT, sez:
cheers OJ, fixed it at last.
i've also put together some lists of material on TDD, BDD, MVC, IoC (DI), and a whole lot more. So many acronyms, so little time.
'Paul Kohler' on Wed, 14 May 2008 21:57:28 GMT, sez:
Nice point about the test runner. I started doing this a while ago (more so for my "functional" tests) and it’s been quite useful. I had the GUI test results pumped into a HTML report file as the tests were executed and these format changes similar to your dodgy mock-up made for a very useful tracking mechanism of the tests - both for me and the team etc.
I do like the idea of doing it to the test runner though... hmmm!
'Csmr' on Fri, 30 May 2008 08:17:15 GMT, sez:
Tests? Tests?!?! Specs? Specks.