Saturday, May 15, 2010

Introducing SpecFlow

Philly .NET Code Camp 2010 was particularly timely, being in conjunction with the Visual Studio 2010 launch. There were 10 different tracks, with numerous well-known speakers and many exciting new .NET features. Despite all of that, one of the more low-profile talks, by Tony Nguyen, on Behavior Driven Development, proved to be the most exciting to me. This talk on BDD and the relatively new product SpecFlow draws heavily on concepts pioneered in the Ruby world through the Cucumber BDD framework.


I had been unconvinced about the full value of BDD prior to this. I could see potential benefits as part of the development process. However, I was skeptical that users, even highly motivated users that are part of an agile process, would be interest in seeing test results. With SpecFlow, instead of just seeing test results as output, quality assurance or end users can write out requirements.


The approach SpecFlow takes is requirements first. The requirements are written in the natural language Gherkin. Conventions are then use to determine the names of tests that should be written. Instead of being test-first, it is requirement first. Running the test suite will confirm or deny the existence of individual test cases and whether they return the proper result. Requirements writers can write cases in notepad and developers can run test suites integrated into Visual Studio. I haven’t provided any details of the Gherkin language but Tony’s presentation, available here, is one good place to start.


There are some immediate questions that are still worth considering before jumping in using SpecFlow. One important question to consider is that given SpecFlow is a fairly new open source project, will it continue to be actively maintained? Another big question is, will there be end-user buy-in into writing requirements in this fashion? Tony has had some success with end users but reports, after less than a year of development with BDD on his most recent project, less than 100% adoption. Organizational culture and management support will affect adoption greatly. Finally, BDD emphasizes integration style tests. How should unit testing be combined, if at all, with BDD tests? In Tony’s case, there test cases are most done in SpecFlow but unit test cases have been written too by some team members.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Concerning future maintenance: SpecFlow is sponsored by TechTalk. TechTalk is providing commercial services and support.
    So if there is a real need for guaranteed maintenance talk to TechTalk. I am sure we can figure out something :-)

    Concerning fitting Acceptance Testing together with Unit Testing: I can highly recommend the book "Growing Object Oriented Software Guided by Tests". This book is brilliant and had a high influence on how I am approaching TDD these days.
    Also there are best-practices evolving out of the Cucumber/Rails community (ie. the RSpec-Book is also a good resource).

    ReplyDelete
  3. Thanks Jonas. It is nice to hear from an active committer to SpecFlow. I have added Growing Object Oriented Software Guided by Tests to my Safari bookshelf.

    ReplyDelete