Agile Continuous Improvement Lunch & Learn
Adventures in SpecFlow
BDD in Data Hub Configuration
(a.k.a. SEC)
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information2
Agenda - 1 hour
• [10 min] - Introduction to BDD & Executable Specifications
• [05 min] - Overview of .NET BDD Tools
• [05 min] - Introducing SpecFlow
• [20 min] - DEMO / Hands on
• [05 min] - Benefits
• [05 min] - Problems & Pro Tips
• [05 min] - BDD vs. Unit Tests
• [05 min] – Conclusion & further study
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information3
Agenda - 1 hour
*NO FREE PIZZA*
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information4
Introduction to BDD & Executable Specifications
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information5
The Question
What does the Customer want?
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information6
Not (only) about testing
1. User Story Acceptance Criteria
2. Shared understanding about outcomes
3. Removes implicit expectations (assumptions)
4. Reduces friction in the team
5. What does our solution do and not do?
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information7
* Driven Development
“Behavior Driven Development” – Dan North
“Specification by Example”
“Executable Specifications”
“Acceptance Test Driven Development” (ATDD)
“Test Driven Development”
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information8
Overview of .NET BDD Tools
(there are a lot)
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information9
.NET BDD Frameworks & Libraries
SpecFlow – Cucumber for .NET
NSpec
MSpec
TestStack.BDDify
NBehave
“Vanila” NUnit/MSTest/xUnit.net
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information10
Explore what’s out there
Have a play and figure out which is best for your team and organisation
SpecFlow is one of many options
A new awesome framework might be released tomorrow
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information11
Introducing SpecFlow
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information12
DEMO
CODE
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information13
Benefits
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information14
Benefits
Human readable (Gherkin - DSL)
Build Context Incrementally
Specification & Documentation
Early discovery of assumptions in acceptance criteria
Early discovery of technical assumptions
Intermediary (Gherkin) between User Story and Code
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information15
Problems & Pro Tips
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information16
Problems & Pro Tips
SpecFlow comes from Cucumber (Ruby)
Sharing state between Steps
Test organisation & structure
Test naming
Mock or end-to-end?
Maintenance
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information17
BDD and Unit Tests
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information18
BDD and Unit Tests
Do SpecFlow Specs replace unit tests?
SpecFlow more suited for larger End-to-end tests
Unit Tests for Devs, BDDS for SCRUM Team & Stackholders
SpecFlow generates NUnit tests automatically
DEMO
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information19
Conclusion
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information20
Conclusion
Sam’s 3 step guide to success!
1. Capture the User Story Acceptance Criteria as Gherkins
2. Implement SpecFlow Specs and iterate with changes to Gherkins [Acceptance Criteria WILL change]
3. You get detailed and correct acceptance criteria and automated regression tests. Everybody wins.
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information21
Conclusion
Was it worth it?
Is anyone going to read our Gherkin Specs?
The effort (money) needed to create and maintain the Specs needs to taken into account
The Team needs to be agile & adopt Gherkin and “Spec first mentality”
Change in thinking & culture
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information22
Further Study
http://stackoverflow.com/questions/307895/what-is-the-most-mature-bdd-framework-for-net
http://www.specflow.org/resources/
Specification by Example [Gojko Adzic, 2011]
The Cucumber Book [Matt Waynne, 2012]
The Art of Unit Testing [Roy Osherove, 2009]
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information23
Questions?
BE AGILE
© Copyright 2011 ADP, Inc. Proprietary and Confidential Information24
Thank you