bdd with visual studio 2012 and specflow

13
Learn how SpecFlow enables you to do TDD with friction-free plain- English executable tests. Larry Apke Agile Expert www.agile-doctor.com [email protected]

Upload: chars

Post on 03-Feb-2016

77 views

Category:

Documents


5 download

DESCRIPTION

BDD with Visual Studio 2012 and SpecFlow. Learn how SpecFlow enables you to do TDD with friction-free plain-English executable tests. Larry Apke Agile Expert www.agile-doctor.com [email protected]. Agenda. Who are You? Who I am and What I Believe What is BDD? SpecFlow Overview - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: BDD with Visual Studio 2012 and SpecFlow

Learn how SpecFlow enables you to do TDD with friction-free plain-English

executable tests.

Larry Apke Agile Expert

[email protected]

Page 2: BDD with Visual Studio 2012 and SpecFlow

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

Page 3: BDD with Visual Studio 2012 and SpecFlow

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 SpecFlow?

Page 4: BDD with Visual Studio 2012 and SpecFlow

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

Page 5: BDD with Visual Studio 2012 and SpecFlow

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 MartinFounder, 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.

Page 6: BDD with Visual Studio 2012 and SpecFlow

• 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, 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

Page 7: BDD with Visual Studio 2012 and SpecFlow

• 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 SpecFlow 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 SpecFlow).

Page 8: BDD with Visual Studio 2012 and SpecFlow

Feature File

Unit Test File Step Definitions File

SpecFlow

Page 9: BDD with Visual Studio 2012 and SpecFlow

Unit Test File

Step Definitions File

SpecFlow

Class File

Test Results File

Test Results Report

Page 10: BDD with Visual Studio 2012 and SpecFlow

• 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-on-a-shoestring/

• Make sure that you add SpecFlow 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

Page 11: BDD with Visual Studio 2012 and SpecFlow

• Batch File Copy and Paste:

@echo offnunit-console %1specflow.exe nunitexecutionreport %2

/xmlTestResult:%3if NOT %errorlevel% == 0 (echo "Error generating report - %errorlevel%"GOTO :exit)if %errorlevel% ==0 TestResult.html:exit

Page 12: BDD with Visual Studio 2012 and SpecFlow

• External Tools Setup:

Title – Run SpecFlowCommand – C:\PATH TO FILE\

nameofbatfile.batArguments - $(TargetName)$(TargetExt) $

(ProjectDir)$(ProjectFileName) $(BinDir)TestResult.xml

Initial Directory - $(BinDir)Check Use Output Window

Page 13: BDD with Visual Studio 2012 and SpecFlow

• Setup Project• Setup the test engine for your project

through NuGet - PM> Install-Package SpecFlow.Nunit

• Create Feature File• Create Step Definitions• Run Test(s)• Write and Refactor