Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

NDC 2011 - SpecFlow: Pragmatic BDD for .NET


Published on

Slides from the session at the Norwegian Developers Conference 2011 by Gaspar Nagy and Jonas Bandi.

Published in: Technology

NDC 2011 - SpecFlow: Pragmatic BDD for .NET

  1. 1. SpecFlow:Pragmatic BDD for .NETNDC 2011 GASPAR NAGY Twitter: @gasparnagy JONAS BANDI Twitter: @jbandiOslo, 8. June 2011 COPYRIGHT 2011, TECHTALK - WWW.TECHTALK.CH
  2. 2. TechTalk at a glance• Established: 1993• Branches: Austria, Hungary, Switzerland• 3 Managing partners: no external owners• Employees: ~ 60 employees• Turnover 2010: ~ 7 Mio CHF• Risk rating: very low risk• Self-financing, healthy growth TechTalk office, Vienna/Austria COPYRIGHT 2011, TECHTALK - WWW.TECHTALK.CH
  3. 3. The audience?• Who is practicing agile Development?• Who is practicing TDD?• Who is doing Acceptance Test Driven Development or Behavior Driven Development?• Who is using Cucumber, Fitnesse, Concordion, NBehave or a similar tool?• Who knows SpecFlow?3
  4. 4. Overview & Agenda• BDD: Summary• SpecFlow Introduction• Demo: SpecFlow Hands On• Demo: MonoDevelop• Q&A The research is partially supported by the project of Eötvös Loránd University: TÁMOP-4.2.1.B-09/1/KMR-2010-00034
  5. 5. BDD – A definition from Dan North BDD is a second-generation, outside-in, pull-based, multiple- stakeholder, multiple-scale, high- automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. Dan North, Agile Testing, Specifications and BDD Exchange 20095
  6. 6. BDD: An attempt to fit it all together Specification by TDD Example Test Driven Development Definition of Done DDD Domain Driven Design BDD Behavior Driven ATDD DSL Development Acceptance Test Driven DevelopmentDomain Specific Language Outside-In User Stories Development 6
  7. 7. Specification by Example • Abstract requirements and specifications are not a good tool for communication. • Concrete examples are much better. • Usually examples are not formalized and not shared. are composed ofExamples Tests elaborate verify & validate Requirements Books by Gojko Adzic7
  8. 8. Detail Discussions… We want to encourage new users to place an order. Therefore we are going to offer 10% discount on every initial order. Register as “bart_bookworm” Go to “/catalog/search” Enter “ISBN-0955683610” Click “Search” Click “Add to Cart” Click “View Cart” Verify “Subtotal” is “$33.75” public void CalculateDiscount(Order order) { if (order.Customer.IsNew) order.FinalAmount = Math.Round(order.Total * 9/10); }8
  9. 9. … Illustrated with Examples Given a user who hasnt placed an order yet When the user puts a book into the shopping cart Then a discount of 10% should be applied on the cart total.9
  10. 10. Show Implicit Expectations Actually, this is not quite right: books on sale should be excluded from discount.10
  11. 11. 3 Amigos Exceptional, Happy Feasibility Edge Cases Path11
  12. 12. TDD12
  13. 13. ATDD: Rising the Level of Abstraction13
  14. 14. Outside-In Development• Always start with a Story• What development should focus on: •Providing business value •Satisfying stakeholder needs 1 •Software that matters 2 3 •Consumable software 4 514
  15. 15. BDD: An attempt to fit it all together Specification by TDD Example Test Driven Development Definition of Done DDD Domain Driven Design BDD Behavior Driven ATDD DSL Development Acceptance Test Driven DevelopmentDomain Specific Language Outside-In User Stories Development 15
  16. 16. SpecFlow• Open-source BDD tool for .NET • •• Focus on high level behavior: features / acceptance tests• Focus on story-style plain text specifications• Using Gherkin as DSL for specifications• Uses existing testing frameworks for execution (Nunit, MSTest, xUnit) • VisualStudio / Build integration16
  17. 17. SpecFlow History• Founded in late 2009 by TechTalk• Goals: • A pragmatic BDD tool for .NET • Provide a frictionless experience for .NET environments • Use existing tools: VisualStudio, UnitTest- Frameworks• SpecFlow is now used in most projects by TechTalk• SpecFlow is used all over the world.18
  18. 18. 19
  19. 19. Integrations… MSBuild MSTest20
  20. 20. ContributorsJonas Bandi, Darren Cauthon, ChristianHassa, Gaspar Nagy, Dale RaganVagif Abilov, Jon Archer, Xerxes Battiwalla,Ryan Burnham, Matt Ellis, Csaba Gerő,John Gietzen, Marcus Hammarberg, KerryJones, Mátyás Kabódi, Avram Korets,Viktor Nemes, Max Paulousky, Chris Roff,Daniel Sack, Attila Sztupák, Charles Weld,Steven Zhang21
  21. 21. DEMO22
  22. 22. tag: specflow “haacked” Phil Haack ASP.NET MVC: A New Framework for Building Web Applications “forked”DEMO23
  23. 23. MonoDevelop Integrationby Dale Ragandale.ragan@sinesignal.comTwitter: @dwragan 24
  24. 24. Teaser Session 2 Requirements Analysis Executable & Automated Specifications Improving Feedback with a Transparent Development Process Living Documentation25
  25. 25. Other BDD Sessions at the NDCThursday Morning:• Gojko Adzic• Scott Bellware 26
  26. 26. Questions &Discussion GASPAR NAGY JONAS BANDI Twitter: @gasparnagy Twitter: @jbandi COPYRIGHT 2011, TECHTALK - WWW.TECHTALK.CH
  27. 27. OtherInterpretations of BDD COPYRIGHT 2011, TECHTALK - WWW.TECHTALK.CH
  28. 28. BDD? – Bushido Driven Development Write good code or kill yourself out of shame. @durp29
  29. 29. Boss Driven Development Beer Driven Development30
  30. 30. Ah ok... I understand. It is done!"BDD? – What? What do you mean?"Bug Driven Well it is done. The system is finished! Well, no ... I dont see an icon where I can start it?Devel- I want you to build YouInstant Social Turbo Oh! an are right. Thats a bug! I will fix it!opment Communication Workstation Terminal ... five minutes later ... Ok, the icon is here. Now it is done! But when I double-click the icon nothing happens! Oh! You are right. That’s a bug! I will fix it. ... five minutes later ... Ok, the app starts when you double click. Now31 it is done!"