views:

623

answers:

4

I just heard about BDD when I watch video of Scott Guthrie in Sweden. One of listener asked question to Scott about How VS2010 and ASP.NET MVC do to support BDD.

After that, I search about BDD (Behavior Driven Development) that focus on specification more than unit testing when compares with TDD (Test Driven Development). I found some framework that work with Ruby and Java. But I do not any famous framework for .NET.

Please suggest me about BDD framework and summary PROs/CONs of it.

PS. Suggested BDD framework must work great on .NET 4, C# 4.0 and ASP.NET MVC 2.

Thanks,

+1  A: 

Have you looked at NBehave? You also probably want to look at this old question. But I would also like to add that IMHO it is possible to do BDD using any kind of unit testing framework. A simple straight forward way is to name your "test class" something like "Given_X" and then let all your "test methods" have names like "It_should_Y".

Cellfish
+1 Been doing BDD for quite some time without a framework.
jamesaharvey
@james you might like http://storyq.codeplex.com since it's a very small framework that basically gives you BDD style reporting from your normal unit tests.
Rob Fonseca-Ensor
+7  A: 

I see this question already has an answer, and I have not tried NBehave. But, we are using MSpec (Machine.Specifications) for this fairly large Enterprise project and it is working quite well for us here. Very well worth mentioning.

Rob Conery did an EXCELLENT video on Learning BDD, where he uses MSpec, line by line: http://blog.wekeroad.com/mvc-storefront/kona-3/

More about MSpec from Rob Conery, and why he uses it.
http://blog.wekeroad.com/blog/make-bdd-your-bff-2/ You might also want to check out his other posts tagged BDD as well.

Pros:

  • Allows for quickly "stubbing" of your entire Story, Scenerios, Contexts, and Specifications - without any actual code. Let's you focus on the overall "Behaviors", which is the purpose of BDD!, without worry about code and making it compile.
  • Produces an EXCELLENT HTML report, with "<- NOT IMPLEMENTED" next to stubbed specifications. I often hand this report to: The Client (CEO and CTO), The Testers, New Resources I bring onto the project, and anyone else that wants to know how the software works - without me having to show a line of code!
  • TestDriven.NET runners are included with MSpec using the new tdnet linking (no setup!).
  • The [Behaviors] attribute, along with its Behaves_like delegate type, makes copying existing specifications from one scenerio over to other another scenerio a snap.

Cons:

  • Little to no documentation, even though not much is needed (watch the videos above). The author recently blogged for help on documenting.
  • Still new, and just a side-project from the author (not his main gig). But, it is very active as of this post.

Hope that helps.

eduncan911
I should also add that with MSpec 0.3, there is now an ReSharper test runner.
eduncan911
Thanks for sharing a lot of information about BDD framework.
Soul_Master
+2  A: 

I built StoryQ after deciding that you didn't need much of a framework. It's very lightweight, embeds in your existing test runner, check it out at http://storyq.codeplex.com

Rob Fonseca-Ensor
Always nice to see someone create their own BDD framework! +1 An OT comment: In your example on the homepage of StoryQ, you show embedded classes. ReSharper's UNit Testing (as of 4.5) does not support embedded classes. You'd be better removing the DemoTest class wrapper, and using more refined Namespaces instead.
eduncan911
@eduncan911 yeah yet another one ;). Hey i'm not sure you mean by "embedded class", the hierarchy is: namespace StoryQ.Demo/class DemoTest/method PassingExample...
Rob Fonseca-Ensor
Doh, you're right. No embedding there. :) Sorry, busy afternoon.
eduncan911
+3  A: 

I'd recommend trying SpecFlow It's weird that no-one's mentioned it. There's a great article here about using BDD with Specflow and Asp.Net MVC It's open source and is hosted on GitHub

Spec flow uses the GWT (Given When Then) syntax which I personally really like. We've had great success so far with BDD now trying to implement using SpecFlow. It's still early days yet but so far it's going well.

Pros:

  1. Integrates into VS2008 & VS2010 with a nice plugin
  2. Uses popular Given When Then vocabulary
  3. Uses standard NUnit Test Runner
  4. Feature file lets you simply paste in Scenarios from Business Analysts

Cons:

  1. the feature code behind is a little ugly, though nothing to bad
  2. As far as I know, the reporting format is fairly limited (i just use NUnit)

I encourage you to give it a go.

danswain