BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

Behavior Driven Development In .NET

by Roopesh Shenoy on Aug 15, 2011 |

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?

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

SpecFlow doesn't just "resemble" Cucumber by Jörg W Mittag

Actually, SpecFlow doesn't just "resemble" Cucumber, both Cucumber and SpecFlow are implementations of the same language, Gherkin.

A video abour BDD : Behavior-Driven Development in the Real World by Pierre Rougier

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

Re: Some other .NET BDD framework by Roopesh Shenoy

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

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

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

Re: TIckSpec by Mark Pawelek

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

10 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT