Behavior Driven Development (BDD) is being increasingly seen as an alternative way to approach Test Driven Development. SpecFlow and NSpec are popular frameworks for BDD in .NET. They help create test specifications that are easy to read even for non-programmers and allow the design of the software to be driven by it’s purpose.
There are two main flavors to BDD – xBehave and xSpec. The first one is good mainly for High level Acceptance testing, whereas the second one is more useful for testing at a unit level. SpecFlow, which resembles Cucumber, falls in the first category, whereas NSpec (closely fashioned on RSpec) falls in the second one. Both are useful in their own ways, and it often makes sense to use both in a project - SpecFlow to cover scenario level tests and NSpec to cover detailed unit level tests.
The advantage of using something like NSpec over a Unit Test framework like NUnit or MSUnit for unit level tests is that it allows to build context incrementally, without complicating the test code. A New Look at Test Driven Development by Dave Astels also gives a very good example of how minor differences make it much easier to write more readable tests by comparing JUnit and RSpec.
There are various tutorials and samples to get you started apart from the project sites themselves.
SpecFlow and NSpec are not the only frameworks available for BDD in .NET, but they seem to be the most popular ones. There are many others like Cuke4Nuke, NBehave and MSpec, each with their own advantages and disadvantages.
BDD, an evolution of Test Driven Development (TDD), was started as an Agile practice to include QA and non-technical or business participants to participate more effectively in a software project. It extends TDD by writing test cases in a natural language in combination with Domain Driven Design to describe the purpose and benefit of code before writing it.
Have you tried Behaviour Driven Development in .NET? If so, what has been your experience?
Community comments
SpecFlow doesn't just "resemble" Cucumber
by Jörg W Mittag,
Some other .NET BDD framework
by Pierre Rougier,
Re: Some other .NET BDD framework
by mike mps,
Re: Some other .NET BDD framework
by Roopesh Shenoy,
Hello Roopesh Shenoy, What about a survey at http://surveymonkey.com/
by Pierre Rougier,
Re: Hello Roopesh Shenoy, What about a survey at http://surveymonkey.com/
by Roopesh Shenoy,
Re: Hello Roopesh Shenoy, What about a survey at http://surveymonkey.com/
by Pierre Rougier,
Re: TIckSpec
by Mark Pawelek,
A video abour BDD : Behavior-Driven Development in the Real World
by Pierre Rougier,
StorEvil
by Pierre Rougier,
Specification by Example with Concordion.NET
by Jacek Ratzinger,
SpecFlow doesn't just "resemble" Cucumber
by Jörg W Mittag,
Your message is awaiting moderation. Thank you for participating in the discussion.
Actually, SpecFlow doesn't just "resemble" Cucumber, both Cucumber and SpecFlow are implementations of the same language, Gherkin.
Some other .NET BDD framework
by Pierre Rougier,
Your message is awaiting moderation. Thank you for participating in the discussion.
SpecFlow
specflow.org/
NBehave
nbehave.org/
SubSpec
bitbucket.org/johannesrudolph/subspec/wiki/Home
StoryQ
storyq.codeplex.com/
Bddify
code.google.com/p/bddify/
BehaveN
code.google.com/p/behaven/
SpecsFor
specsfor.codeplex.com/
Behavioral
behavioral.codeplex.com/
MSpec
github.com/machine/machine.specifications
A video abour BDD : Behavior-Driven Development in the Real World
by Pierre Rougier,
Your message is awaiting moderation. Thank you for participating in the discussion.
A video abour BDD :
Behavior-Driven Development in the Real World
channel9.msdn.com/Events/TechEd/NorthAmerica/20...
Re: Some other .NET BDD framework
by mike mps,
Your message is awaiting moderation. Thank you for participating in the discussion.
Raconteur
raconteur.github.com
StorEvil
by Pierre Rougier,
Your message is awaiting moderation. Thank you for participating in the discussion.
github.com/davidmfoley/storevil/wiki
Re: Some other .NET BDD framework
by Roopesh Shenoy,
Your message is awaiting moderation. Thank you for participating in the discussion.
Thanks Peirre, that's a good amount of additional info, in both this and the other comments.
Hello Roopesh Shenoy, What about a survey at http://surveymonkey.com/
by Pierre Rougier,
Your message is awaiting moderation. Thank you for participating in the discussion.
Hello Roopesh Shenoy,
What about a survey at surveymonkey.com/ , or elsewhere ?
which is your favorite BDD framework in 2011 ?
Re: Hello Roopesh Shenoy, What about a survey at http://surveymonkey.com/
by Roopesh Shenoy,
Your message is awaiting moderation. Thank you for participating in the discussion.
That sounds interesting Pierre, but I will have to get a good sample to do justice. Anyways, this is just an introductory post, I was hoping to run more posts/articles on this topic in future.
Do you have any experience in BDD that you would like to share with the InfoQ audience maybe as an article? If so do let me know, you can contact me at roopesh.shenoy@vagsons.com.
Re: Hello Roopesh Shenoy, What about a survey at http://surveymonkey.com/
by Pierre Rougier,
Your message is awaiting moderation. Thank you for participating in the discussion.
or uservoice.com/
Re: TIckSpec
by Mark Pawelek,
Your message is awaiting moderation. Thank you for participating in the discussion.
tickspec.codeplex.com/
Specification by Example with Concordion.NET
by Jacek Ratzinger,
Your message is awaiting moderation. Thank you for participating in the discussion.
An important aspect of BDD is the collaboration between different stakeholders of software projects to gain a common understanding of the requirements. A framework that enables to involve many stakeholders is Concordion.NET, as it is based on html and can be easily accessed by non-technical people:
concordion.org/dotnet/