Acceptance
Test
Driven
Development
What is the difference
with
TDD?
Unit Tests
One class
One method
No dependencies
(mocks)
Core of TDD
Rules of TDD
http://bit.ly/1fnUgW6
You are not allowed to
write any production
code unless it is to make a
failing unit test pass.
Rule #1
You are not allowed to
write any more of a unit
test than is sufficient to
fail; and compilation
failures are failures
Rule #2
You are not allowed to
write any more
production code than is
sufficient to pass the one
failing unit test
Rule #3
1. Unit Test First (no excuse)
2. Minimal test code
3. Minimal production code
Summary
More than
one class
Communication
between
components
Acceptance tests
What is the limit
of TDD?
Expectations
Reality
What happened?
End to end
Black box testing
Works with
Legacy Code
Works with
New Code
Works with
-40!!!
Core of BDD
(also called ATDD)
Narrowing the gap
Fail Fast
Where can we fail?
Analysis?
Implementation?
QA?
Deploy?
Demo?
Acceptance Criteria
First
Rules of ATDD
You are not allowed to
write any unit test code
unless it is to make a
failing acceptance
criteria pass.
Rule #1
You are not allowed to
write any more of one
acceptance criteria that
is sufficient to fail
Rule #2
Define your acceptance
criteria as a group
Rule #3
1. Acceptance Criteria First
2. Minimal TDD
3. Define the criteria as a
group
Summary
ATDD Flow
Write a Criteria
Pass?
TDD Cycle
NOYES
Feature Driven
Benefits
Adding value on
every step
Benefits
High Quality
Benefits
Regression
Testing
Benefits
Writing Scenarios
(Acceptance Criteria)
A User Story
may have multiple paths
Each path represents a
possible scenario
Each scenario is a
sequence of steps
Each scenario is a
sequence of steps
Write scenarios for a user
login story
Post-It
&
Sharpie!
Exercise
Scenario: Valid credentials
Given I have valid credentials
When I login to the movie library
Then I see my dashboard
User Login
Scenario: Invalid credentials
Given I don’t remember my password
When I login to the movie library
Then I see a message to recover my
password
User Login II
Scenario: Using google Oauth
Given I have an account with google
When I login choosing google
Then I can see my dashboard
User Login II
Gherkin DSL
Given
The state of the application
in order for the scenario to
run successfully
When
The action that has to be
completed in the current
scenario
Then
The acceptance criteria
that the scenario uses in
order to ensure success
Rewrite one of your
scenarios using
Given, When, Then, And
Post-It
&
Sharpie!
Exercise
Guidelines
_ _ _ _ _ _ _ _ _ ?
Scenario: Everything is awesome
Given the application is setup
When I want to use some projects
Then I should be able to load data
And have a great user experience
but no bugs should appear
Scenario: Redirect user to originally requested page
Given a User "dave" exists with password "secret"
And I am not logged in
When I navigate to the home page
Then I am redirected to the login form
When I fill in "Username" with "dave"
And I fill in "Password" with "secret"
And I press "Login"
_ _ _ _ _ _ _ _ _ ?
Scenario: List all projects
Given I'm logged in
And I have some projects stored
When I list all the projects
Then I should see all of them
_ _ _ _ _ _ _ _ _ ?
Complexity
How can we estimate a
feature using scenarios?
COMPLEX ∝ #SCENARIOS
0
1
2
4
5
6
7
Simple Medium Complex WTF?
Scenarios
Complexity
COMPLEXITY ∝ CLARITY
Too many steps
Too long to write
Nobody can understand it
Scenario Order
What should go first?
List movies or create
movies?
Size Matters
How many scenarios per
story?
Make every story around the
same size
•One or two scenarios most
•Or break it down
Recipe - Step I
Time limit (days) to each
feature
•After one or two days
•break it down
Recipe - Step II
Choose simplest story-
scenario to flush out
implementation and discover
new requirements
Recipe - Step III
Demo
Summary
Benefits
• Easier planning
• Discovers functionality
and complexity
• No particular skill
required
• Easy Adoption
• Puts the whole team
on the same page
• Simplifies QA process
• Narrows the gap
between expectations
and actual
implementation
Challenges
•Requires discipline
•Owner must participate
•Roles get blured
•QA changes drastically
Thank you!
amir@barylko.com
@abarylko
http://bit.ly/abarylkop
Photo Credit
• Under http://creativecommons.org/licenses/by/2.5/
• Joe Cheng, DSC_7820-01, http://flic.kr/p/2Zt2u
• Bill Ward, Derek Schin's Trucks 1, http://flic.kr/p/m5L5S
• Jeremy Keith, Roast beef, http://flic.kr/p/TKUz
• Rob Campbell, Field of daisies, http://flic.kr/p/6QJjU4
• Karin Dalziel, The Thinker, http://flic.kr/p/4UYArc
• Under http://creativecommons.org/licenses/by-sa/3.0/us/
• Derick Bailey, SOLID Motivational Posters, http://bit.ly/17aVaHg
Photo Credit 2
• How to write good code, http://xkcd.com/844/
• Understanding flow charts, http://lifehacker.com/5909501/how-to-
choose-the-best-chart-for-your-data

Acceptance Test Driven Development