Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
why-tdd
1. AMIR BARYLKO
WHY TDD?
WPG RUBY UG 2011
Amir Barylko - TDD MavenThought Inc.
2. INTRO
Why projects fail?
Reality Check
No more excuses
Why TDD?
Amir Barylko - TDD MavenThought Inc.
3. WHY PROJECTS FAIL?
• Delivering late or over budget
• Delivering the wrong thing
• Unstable in production
• Costly to maintain
Amir Barylko - TDD MavenThought Inc.
4. REALITY CHECK
• It is impossible to gather all the requirements at
the beginning of a project.
• Whatever requirements you do gather are
guaranteed to change.
• There will always be more to do than time and
money will allow.
Amir Barylko - TDD MavenThought Inc.
5. NO MORE EXCUSES
• It works on my computer! • We need a satellite
connection in order to
• Itwas like that when I got run it!
here!
• We can’t reproduce the
• The previous developer error!
didn’t know XXXX!
• We can’t test that!
Amir Barylko - TDD Workshop PRDC 2011 MavenThought Inc.
6. WHY TDD?
• Prove that your code • Regression tests as
works byproduct
• Avoid waste • Makechanges with
(debugging) confidence
• Increment code quality • Bring
back the joy of
coding!
• Better design
Amir Barylko - TDD Workshop PRDC 2011 MavenThought Inc.
7. APPLYING TDD
Iteration 0 .. N
Quality as a Driver
Red - Green - Refactor
Amir Barylko - TDD MavenThought Inc.
8. ITERATION 0
• Flush out architecture.
• Setup Testing harness for TDD and BDD.
• Setup continuous integration.
• Setup scripts to build, deploy, etc.
• Setup visual communication tools.
Amir Barylko - TDD MavenThought Inc.
9. ITERATION 1.. N
• Start by Story Planning
• Pair programming (switching often) Every day!
• Daily Scrum
• End with Retrospective
Amir Barylko - TDD MavenThought Inc.
10. QUALITY AS A DRIVER
Red
BDD
Red
Refactor Refactor TDD Green Green
Amir Barylko - TDD MavenThought Inc.
11. RED
•Write a test that fails
•Relax, is ok if it compiles
Amir Barylko - TDD MavenThought Inc.
12. GREEN
• Try to make the test pass
• Do a simple solution
• Use default values (not throwing exceptions)
• Don’t worry if the code “smells”
Amir Barylko - TDD MavenThought Inc.
13. REFACTOR
• Avoid repeating code
• Avoid hardcoding dependencies
• Avoid “write only” code
• Refactor with confidence!
• Run all tests if possible
Amir Barylko - TDD MavenThought Inc.
14. DEMO
MediaLibrary
Add
Top10
Amir Barylko - TDD MavenThought Inc.
15. SUMMARY
Limits
Benefits
Challenges
Adoption
Amir Barylko - TDD MavenThought Inc.
16. LIMITS OF TDD
• Unit test
• Integration test
• Acceptance test
Amir Barylko - TDD MavenThought Inc.
17. BENEFITS
• Let the methodology drive
• It will save your bacon!
• High quality the whole way!
• Very few bugs!
• Do your duty as developer!
Amir Barylko - TDD MavenThought Inc.
18. CHALLENGES
• Very different from conventional testing
• Many developers find it complex to learn at first
• Hard to start without a Mentor
• Management buy in
• Difficult to keep under deadline pressure
• Beware of code coverage!
Amir Barylko - TDD MavenThought Inc.
19. ADOPTION
• Find Mentor/Couch/Trainer
• Small iterations
• Have metrics ready (velocity, etc)
• Do whatever works for you
• Find out which tools will benefit you
• Automate, automate, automate!
Amir Barylko - TDD MavenThought Inc.