SpecFlow, Gherkin	


and some things 	

I’ve picked up using them

Marcus Hammarberg
Specification by example	

is not about the tools	

!

it’s about communication
Whether we choose to call it BDD or ATDD or
Specification by Example, we want the same
result – a shared common understanding of
what is to be built 	

to try to build the ‘thing’ right the first time. 	

!

We know it never will be, but the less rework,
the better.	

!
Janet Gregory
Hence: Let’s talk tools!

http://boulderblimp.com/blimpwp/wp-content/uploads/2012/03/Craftsman-Toolbox.jpg
http://www.youtube.com/aptitudsthlm
Bandung
It’s not in the tool

http://www.barbellsandbacon.com/wp-content/uploads/2010/02/mlss_mario-hammer.jpg
Tools
How does this work?
How does this work?

[Given("I am on the Activity list")]
public void ThisNameIsNotImportantToSpecFlow()
!

[When("I click the Create New link")]
public void SpecFlowUsesTheAttirbutesPerDefault()
!

[Then("I should be on the Create Activity page")]
public void SoItDoesntEvenCareWhatYouCallThese()
Gherkin
Feature

http://www.lushtshirts.co.uk/images/products/bug-feature.jpg
Feature

http://www.lushtshirts.co.uk/images/products/bug-feature.jpg
Feature

http://www.lushtshirts.co.uk/images/products/bug-feature.jpg
Scenario

http://images2.fanpop.com/images/photos/7000000/Friends-33-friends-7046166-1280-1024.jpg
Scenario

http://images2.fanpop.com/images/photos/7000000/Friends-33-friends-7046166-1280-1024.jpg
Scenario

http://images2.fanpop.com/images/photos/7000000/Friends-33-friends-7046166-1280-1024.jpg
Step in time!
Step in time!
Expressions
Expressions
When I withdraw $20
Expressions
When I withdraw $20

[When(@“I withdraw $(d+)“)]
public void Withdraw(int amount)
Expressions
When I withdraw $20

[When(@“I withdraw $(d+)“)]
public void Withdraw(int amount)

(.*) => string	

(d+) => integer
Background
Hooks
Hooks
Tags
Tags
@ignore
[Given("I have the following persons")]
public void IHaveTheFollowingPersons
(Table personsTable)
SpecFlow.Assist
SpecFlow.Assist
Scenario outline
Scenario outline
Language
ScenarioContext.Current
Do I have time for more?

http://appyourmac.com/wp-content/uploads/2009/06/Awaken.png
Code here:
http://bit.ly/SpecFlowDemos
Cuke Envy
Gherkin
Gherkin
Step 	

definition
Gherkin
Step 	

definition
DSL
Gherkin
Step 	

definition
DSL
Automation	

code
Gherkin
Step 	

definition
DSL
Automation	

code
SUT
Here’s one I’ve
prepare earlier
Here’s one I’ve
prepare earlier

http://media.kansascity.com/smedia/2013/02/13/13/33/meBc3.St.81.jpeg
Structure
Structure
Coding by intention
Structure
Coding by intention
Pushing the HOW down
Structure
Coding by intention
Pushing the HOW down
DSL Swap
A special thank you
to my friends:
- Cucumber
• SpecFlow(specflow.org)	

on .NET, great Visual Studio
integration

• NancyFx - Minimalistic web framework, with great
testing capabilities (nancyfx.org)	

• Simple.Data - simple data access,	

that’s all
(github.com/markrendle/Simple.Data)
• FluentAutomation - UI Automation, wraps
Selenium/Watin/etc (fluent.stirno.com)
Code here:
http://bit.ly/CukeEnvy
Learn more
Learn more
• http://blog.dannorth.net/introducing-bdd/
Learn more
• http://blog.dannorth.net/introducing-bdd/
• http://www.specflow.org/
Learn more
• http://blog.dannorth.net/introducing-bdd/
• http://www.specflow.org/
• http://cukes.info
Learn more
• http://blog.dannorth.net/introducing-bdd/
• http://www.specflow.org/
• http://cukes.info
• https://github.com/marcusoftnet/SpecFlowDemos
Learn more
• http://blog.dannorth.net/introducing-bdd/
• http://www.specflow.org/
• http://cukes.info
• https://github.com/marcusoftnet/SpecFlowDemos
• http://skillsmatter.com/podcast/agile-testing/refuctoring-yourcukes
Learn more
• http://blog.dannorth.net/introducing-bdd/
• http://www.specflow.org/
• http://cukes.info
• https://github.com/marcusoftnet/SpecFlowDemos
• http://skillsmatter.com/podcast/agile-testing/refuctoring-yourcukes

• http://skillsmatter.com/podcast/agile-testing/bdd-as-its-meantto-be-done
Learn more
• http://blog.dannorth.net/introducing-bdd/
• http://www.specflow.org/
• http://cukes.info
• https://github.com/marcusoftnet/SpecFlowDemos
• http://skillsmatter.com/podcast/agile-testing/refuctoring-yourcukes

• http://skillsmatter.com/podcast/agile-testing/bdd-as-its-meantto-be-done

• http://skillsmatter.com/podcast/agile-testing/cuke-envy-a-dotnet-programmers-attempt-to-catch-up
www.marcusoft.net	

@marcusoftnet	

marcus.hammarberg@aptitud.se
www.marcusoft.net	

@marcusoftnet	

marcus.hammarberg@aptitud.se
Recording of this talk	

http://www.youtube.com/
aptitudsthlm
SpecFlow and some things I've picked up

SpecFlow and some things I've picked up