Usage With A Domain Model

Sep 18, 2007 at 7:20 AM
Having read a bit about BDD I'm interested to know how you would use it to test/specify a domain model, I'm thinking (based on your excellent description of BDD at http://dannorth.net/introducing-bdd) it would be something like this:

1) Get your domain expert, or someone working closely with the domain expert, to specify the BDD tests in textual form.
2) Add the delegates needed to exercise the code under test, using mocking to specify the expected behavior/interaction.
3) Write the code to support the new behavior, using TDD as you go.
4) As you write the new domain classes/members you will be able to gradually remove the mocking so once the implementation is complete your story will only be exercising real domain objects.

Is this how you see it working?
Coordinator
Sep 18, 2007 at 10:40 PM
Mocking as you go definitely is an interesting approach. Personally, it doesn't quite give enough feedback in the scenario results telling me which ones are passing and which ones are still mocked.

I like to use the "Pending" feature for that one. Typically, the code isn't written yet when I put the scenarios into NBehave, so even mocking would be premature, or even put me in a direction I don't want to go. I usually go to finer-grain behaviors doing TDD, then come back up to the scenario level and complete the story. NBehave tells me I have pending scenarios (and even a pending reason), so I can see pretty clearly which scenarios still need to be completed.

Not to say mocking or stubbing details that aren't implemented yet isn't necessarily a bad idea, it's just tougher for me to get good feedback from that approach.

Hope this helps!
Sep 19, 2007 at 2:09 PM
Edited Sep 23, 2007 at 6:08 PM
Thanks for the clarification, and that definitely makes a lot of sense. It might be worth making the expected usage clear with an example on this site though as at the minute the many BDD descriptions on the Web all give slightly different descriptions of how to apply BDD.