BDD with Visual Studio 2012 and Spec Flow

BDD with Visual Studio 2012 and Spec. Flow Learn how Spec. Flow enables you to do TDD with friction-free plain-English executable tests. Larry Apke Agile Expert www. agile-doctor. com larry@agile-doctor. com

• • • Agenda Who are You? Who I am and What I Believe What is BDD? Spec. Flow Overview Visual Studio 12 Spec. Flow Installation Interacting with Code!

• • • Who are you? How many. net programmers? How many using Visual Studio 2012? How many familiar with TDD? How many familiar with BDD? How many using/used Spec. Flow?

Who I am: • A Certified Scrum Master and Certified Scrum Professional with over 5 years experience in Agile development. • A former Director of Software Development, Manager of Software Development, Project Manager, etc. Who I am not: • A. Net Programmer

What I believe: • If you are a programmer and have not acquainted yourself with and mastered BDD/TDD then you are no longer a true craftsman. “TDD is probably the single most important practice discovered in the last 10 years. “ - Robert Martin Founder, CEO and President Object Mentor Inc. • Without automated executable specifications (like those created through BDD), it is nearly impossible to be truly Agile. • Over the next five years BDD/TDD will become THE standard for software development.

What is BDD (Behavioral Driven Development)? • BDD is a software development process based on test -driven development (TDD). Sometimes described as “TDD done right. ” • Developed by Dan North as a response to the issues encountered teaching test-driven development. • “BDD is a second-generation, outside–in, pull-based, multiple-stakeholder, multiple-scale, highautomation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters. ” – Dan North

What is BDD (Behavioral Driven Development)? • BDD utilizes Ubiquitous Business Language (UBL), which is composed of plain English, to create executable specifications. • Because of UBL, BDD is concerned with the communication between business needs and developers. • BDD allows for frameworks like Spec. Flow to automate the running of the executable specifications by using Scenarios written using the Gherkin language (Given, When, Then) - called Gherkin because of Cucumber (a Ruby BDD Framework that inspired Spec. Flow).

Input Spec. Flow Overview – File Creation Feature File Output Spec. Flow Unit Test File Step Definitions File

Spec. Flow Overview – Running Tests Spec. Flow Unit Test File Test Results File Step Definitions File Test Results Report Class File

Visual Studio 12 Spec. Flow Installation • Easy to install with Visual Studio Gallery • Nearly impossible to get working under Visual Studio Express but you can try http: //watirmelon. com/2011/02/18/c-sharp-atdd-ona-shoestring/ • Make sure that you add Spec. Flow and Nunit to your Windows path • If you use Nunit you will need something to run the tests – like Resharper– but you can create a batch file that will run Nunit and add it to your Tools menu

Visual Studio 12 Spec. Flow Installation • Batch File Copy and Paste: @echo off nunit-console %1 specflow. exe nunitexecutionreport %2 /xml. Test. Result: %3 if NOT %errorlevel% == 0 ( echo "Error generating report - %errorlevel%" GOTO : exit ) if %errorlevel% ==0 Test. Result. html : exit

Visual Studio 12 Spec. Flow Installation • External Tools Setup: Title – Run Spec. Flow Command – C: PATH TO FILEnameofbatfile. bat Arguments - $(Target. Name)$(Target. Ext) $(Project. Dir)$(Project. File. Name) $(Bin. Dir)Test. Result. xml Initial Directory - $(Bin. Dir) Check Use Output Window

Interacting with Code • Setup Project • Setup the test engine for your project through Nu. Get - PM> Install-Package Spec. Flow. Nunit • Create Feature File • Create Step Definitions • Run Test(s) • Write and Refactor
- Slides: 13