3. What are ATDD & BDD?
ATDD → Acceptance Test Driven
Development
BDD → Behavior Driven
Development
Both build on the concepts of Test
Driven Development (TDD)
4. 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?
5. 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
6. Two Types of BDD
xSpec
Unit test level
Includes NSpec and Machine.Specifications
xBehave
Higher level acceptance testing
Includes Nbehave and SpecFlow
7. 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
8. Collaboration among product owners, developers,
and testers (Three Amigos)
Product owners write gherkin
Developers write code against gherkin
Testers ensure the gherkin works
13. Gherkin
Feature: 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.
15. SpecFlow - Platforms
Supports the following platforms:
.NET Framework
Silverlight
Windows Phone
Mono
16. SpecFlow - Installation
MSI file for Visual Studio 2008 integration
NuGet
Visual Studio Gallery
17. SpecFlow - Test Runner Support
Visual Studio 2012 built-in test runner
ReSharper
SpecRun
18. SpecFlow Workflow
• Three Amigos
ATDD • Talk about features
Specify • Write gherkin
• Write code to fulfill
those features
• Run the feature tests
Deliver Develop • Fix code to meet
features if they
aren’t passing.
Once all tests past • Retest
Once all acceptance criteria
has been fulfilled
20. 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