What Behavior Driven Development (BDD) Tooling/Frameworks are available for the Microsoft Stack? [closed]

爷,独闯天下 提交于 2019-12-20 08:38:47

问题


I am interested in Behavior Driven Development (BDD)

Are there any good frameworks and/or tooling available for the .Net platform (preferably C# and ASP.Net)?

And when has BDD proved most appropriate to use in real world scenarios? (auxiliary question)


回答1:


On googling I found Behavior Driven Development (BDD) with SpecFlow and ASP.NET MVC. You might find it useful, take a look. Also go through Behavior-Driven Development with SpecFlow and WatiN

A nice presentation on Pros and Cons of BDD

A channel 9 video Behavior-Driven Development in the Real World

and last but not least an InfoQ article Behavior Driven Development In .NET




回答2:


+1 for people's recommendation of SpecFlow for scenarios; never used it but heard many good things about it. I've been using plain old NUnit with a little DSL like this. MSTest would work similarly.

You can also do BDD in the unit space, which is what MSpec is designed to do. I'm personally hating MSpec, but the rest of the team here love it. They like writing examples of how the code works. I like to show why the behavior is valuable. It's a subtle distinction and if you're not worried about doing this at a unit level it won't hit you.

Other frameworks to look at include Concordion, Fitnesse.NET (please put FitSharp behind it!) and TickSpec.

In the real world, the most valuable bit of BDD by a long way is the conversations, not the automated tests. Here's a couple of quick hints and tips for making it work:

  • Don't write automated tests over things which are in flux. It just commits you to stuff you got wrong. Wait until the UI has settled a bit then do it.

  • If you don't care much about your UI, but do care about data integrity, write the scenarios over the controller / presenter layer (eg: for admin screens).

  • Don't start with login. Start by describing a valuable part of the application for which you might log in. Do that first (assume you only have one user). You'll get quicker feedback on the risky bits.

  • Seek quick feedback on the risky bits, which will usually be the bits which you've never done before. Use scenarios to have conversations around them. Write anything interesting you discover down, but forget the scenarios which are obvious - they're obvious! Don't worry about automating them to start with. Having conversations is more important than writing down conversations is more important than automating conversations.

Good luck! If you want to know more about BDD, I put together a page of relevant links here.




回答3:


LightBDD is an open source framework allowing to write BDD tests that are easy to read but also easy to maintain and extend when project grows larger.

The main features that it offers are:

  • easy to read scenarios,
  • easy maintenance of tests,
  • integration with well known testing frameworks (NUnit / MbUnit / MsTest / xUnit),
  • scenario steps execution tracking and execution time measurement,
  • test execution summary report generation in HTML (an example report), XML and plain text format.

It bases on tests that are written purely in code, which means native support for refactoring, code analysis, test running and all other features that Visual Studio / Intellisense / Resharper offers.

An example test written in this framework looks as follows:

[TestFixture]
[FeatureDescription(
@"In order to access personal data
As an user
I want to login into system")] //feature description
[Label("Story-1")]
public partial class Login_feature //feature name
{
    [Test]
    [Label("Ticket-1")]
    public void Successful_login() //scenario name
    {
        Runner.RunScenario(

            Given_user_is_about_to_login, //steps
            Given_user_entered_valid_login,
            Given_user_entered_valid_password,
            When_user_clicked_login_button,
            Then_login_is_successful,
            Then_welcome_message_is_returned_containing_user_name);
    }
}

More information about framework could be found on project wiki page and project main page.




回答4:


Also MSpec is a good framework.

I use it in the Microsoft stack you mention (C#, ASP.Net and MVC) and I like his syntax.

BDD helps you thinking in business/feature oriented way not just in a code way. So you are most focused on business value.

It also helps in user acceptance test to create a trust between you and customer.




回答5:


There is a great tool, called SpecFlow. SpecFlow is inspired by Cucumber — the well known BDD framework for Ruby on Rails. And has a huge amount of advantages.

You should definitely check it out.




回答6:


One interesting BDD frameworks is Concordion.NET. It is an open source BDD framework for the Microsoft stack that uses NUnit to execute the Concordion.NET tests: https://github.com/concordion/concordion-net As Concordion specifications are written in simple HTML, it provides a good basis for a living documentation system. You can use a what-you-see-is-what-you-get (WYSIWYG) editor like BlueGriffon to describe your intended behavior of your software in simple HTML documents and instrument them to verify your system under test. According to the excellent classification of BDD tools, Concordion.NET focuses on business readable input (and reaches business readable output as well). It moves even beyond BDD and supports ATDD: http://assertselenium.com/2012/11/05/difference-between-tdd-bdd-atdd/




回答7:


Spec4Net (https://bitbucket.org/fthomsen/spec4net/) is a nice framework too. We use it extensively at work. The learning curve is almost non-existing and the natural flow seems intuitive.



来源:https://stackoverflow.com/questions/8922079/what-behavior-driven-development-bdd-tooling-frameworks-are-available-for-the

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!