spec(ing) out your workflow with specflow
DESCRIPTION
Presented at the Cleveland WPF User Group on October 16, 2012TRANSCRIPT
Agenda
Brief Intro to ATDD & BDD
.NET Tools for ATDD & BDD
Workflow
Gherkin
SpecFlow overview
Demo
What are ATDD & BDD?
ATDD → Acceptance Test Driven
Development
BDD → Behavior Driven
Development
Both build on the concepts of Test
Driven Development (TDD)
Behavior Driven Development
Goes beyond unit testing and looks at the system as a whole
Top down/ outside in
Describes how the application is going to be used through
executable examples
The question is “What’s the intended behavior?”
What should it do?
BDD Guidelines
Test method names should be sentences – helpful for finding failing
tests and understand what the behavior class does
Use “behavior” instead of “test”
Requirements are considered behaviors
Ubiquitous language (gherkin)
As a … I want… so that …
Given… When… Then
Criteria should be executable
Two Types of BDD
xSpec
Unit test level
Includes NSpec and Machine.Specifications
xBehave
Higher level acceptance testing
Includes Nbehave and SpecFlow
ATDD
Subset of BDD, focusing on the acceptance criteria
Criteria first, then tests written, then code
Document that describes the behaviors in the system
Detail out the specification – specific business rules and any other
specifics to help devs understand
Defects are discovered quicker – in discussing the acceptance
criteria rather than waiting for testing
High level examples of how the software will be used
Collaboration among product owners, developers,
and testers (Three Amigos)
Product owners write gherkin
Developers write code against gherkin
Testers ensure the gherkin works
Collaboration Breeds Innovation
.NET ATDD/BDD Tools
xBehave
StoryQ
SpecFlow
xSpec
Nspec
Machine.Specifications
Workflows
Red
GreenRefactor
TDD
Specify
DevelopDeliver
ATDD
Examples
RequirementsVerifyTests
GherkinFeature: Collaboration
In order to ensure successful product development,
I want to collaborate with the team in all phases.
Scenario: The Goal of the Product Owner
Given I am the Product Owner
When I write feature files
Then developers and testers have documentation to help ensure that the product is what I want.
Scenario: The Goal of the Developer
Given I am the Developer
When I have the feature files
Then I can write the code for those features
Scenario: The Goal of the Tester
Given I am the Tester
When the Developer is done writing the code for a feature
Then I can test the code to make sure it fulfills that feature’s requirements.
More Gherkin – Conjunctions!
SpecFlow - Platforms
Supports the following platforms:
.NET Framework
Silverlight
Windows Phone
Mono
SpecFlow - Installation
MSI file for Visual Studio 2008 integration
NuGet
Visual Studio Gallery
SpecFlow - Test Runner Support
Visual Studio 2012 built-in test runner
ReSharper
SpecRun
SpecFlow Workflow
Specify
DevelopDeliver
ATDD• Three Amigos
• Talk about features
• Write gherkin
• Write code to fulfill
those features
• Run the feature tests
• Fix code to meet
features if they
aren’t passing.
• RetestOnce all tests past
Once all acceptance criteria
has been fulfilled
DEMO
Resources
Gherkin
Cucumber Project Documentation on GitHub
Books
Cucumber & Cheese: A Testers Workshop by Jeff Morgan
The Cucumber Book: Behaviour-Driven Development for Testers and
Developers by Matt Wynne and Aslak Hellesøy
Specification by Example by Gojko Adzic
SpecFlow
C# ATDD on a shoestring (or the complete guide to SpecFlow & Nunit in Visual Studio 2010 Express) on WatirMelon by Alister Scott
Contact Information
Twitter: @sadukie
LinkedIn: http://www.linkedin.com/profile/view?id=27521335
Email: [email protected]