A Beginners Guide to
Test Driven Development
Developing Sustainable Software….
Naresha K.,
Software Craftsman
Twitter: @na...
Disclaimer
The opinions or views expressed
in this presentation are solely of
the speaker and do not necessarily
represent...
You are Here
http://www.flickr.com/photos/oldben/2322196242/
The Roadmap
You are
here Threat Driven Development
Destination Test Driven Development
The Significance
Never
in the field of software development
have so many owed
so much to
so few lines of code
The Problems
http://www.flickr.com/photos/donnagrayson/195244498/
Cost of Change
2
20
50
100
150
500
Analysis Design Coding Integration Acceptance Production
Cost
Cost
Time To Market
http://www.flickr.com/photos/cobalt/5800169708/
Sustainable Software
http://www.flickr.com/photos/sillygwailo/146872543/
We are only afraid of…
http://www.flickr.com/photos/spursfan_ace/2328879637/http://www.flickr.com/photos/crystaljingsr/391...
We are only afraid of…
http://www.flickr.com/photos/spursfan_ace/2328879637/
Planning – The Waterfall way
http://www.flickr.com/photos/vizzzual-dot-com/2655969483/
The waterfall way
Analysis
• 2
weeks
Design
• 3
weeks
Code
• 4
weeks
Test
• 4
weeks
Release
• 14th
week
The fall of waterfall
Analysis
• 2
weeks
• 2
weeks
Design
• 3
weeks
• 4
weeks
Code
• 4
weeks
• 5
weeks
Test
• 4
weeks
• 2
...
Testing can only indicate the quality
http://www.flickr.com/photos/24560044@N08/5726488676/
But Feedback is Important
When to receive feedback?
• Closest to the incident
• Frequently
• You get more time to act upon
Test Early Approach
• Test as and when you complete small chunk of
code (say a function – is it small?)
• Integrate
– Earl...
Nature of Business Environment
http://www.flickr.com/photos/oldben/2301828397/
Mistaken Assumption
http://www.flickr.com/photos/9465588@N05/3302103347/
The Solution
Embrace Change
Automated Testing
• Mitigates
– Integration testing cost
– Regression testing cost
Benefits
• S - Savings through early integration
• C - Cost of automating tests
• ROI = S / C
• (Small + Often) integratio...
Still Problems !!
http://www.flickr.com/photos/mosmancouncil/3361174929/
Waste
• Unused Code
• Lack of modularity
The Ultimate Solution
• Write test code before production code
How Writing Tests Help?
• Clarifies the acceptance criteria
• Encourages to write loosely coupled
components
• Adds execut...
How Running Tests Help?
• Detects errors (early)
• Lets us know when we have done enough
• Avoid unnecessary features
Test Driven Cycle
1. Write
failing Tests
2. Write code
pass tests
3. Refactor
TDD – Rule #1
No code will be written
without a failing test
TDD – Rule #2
No more tests will be written
Than sufficient to fail
TDD – Rule #3
No more code will be written
than sufficient to pass
failing tests
Demo
Feedback from tests
Unit tests End-End testing
AmountofFeedback
Internal Quality Feedback
External Quality Feedback
White ...
http://www.flickr.com/photos/winning-information/2325865367/
http://www.flickr.com/photos/winning-information/2325865367/
Upcoming SlideShare
Loading in …5
×

A beginners guide to Test Driven Development

1,658 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,658
On SlideShare
0
From Embeds
0
Number of Embeds
143
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

A beginners guide to Test Driven Development

  1. 1. A Beginners Guide to Test Driven Development Developing Sustainable Software…. Naresha K., Software Craftsman Twitter: @naresha_k
  2. 2. Disclaimer The opinions or views expressed in this presentation are solely of the speaker and do not necessarily represent the views of my employer.
  3. 3. You are Here http://www.flickr.com/photos/oldben/2322196242/
  4. 4. The Roadmap You are here Threat Driven Development Destination Test Driven Development
  5. 5. The Significance Never in the field of software development have so many owed so much to so few lines of code
  6. 6. The Problems http://www.flickr.com/photos/donnagrayson/195244498/
  7. 7. Cost of Change 2 20 50 100 150 500 Analysis Design Coding Integration Acceptance Production Cost Cost
  8. 8. Time To Market http://www.flickr.com/photos/cobalt/5800169708/
  9. 9. Sustainable Software http://www.flickr.com/photos/sillygwailo/146872543/
  10. 10. We are only afraid of… http://www.flickr.com/photos/spursfan_ace/2328879637/http://www.flickr.com/photos/crystaljingsr/3914729343/
  11. 11. We are only afraid of… http://www.flickr.com/photos/spursfan_ace/2328879637/
  12. 12. Planning – The Waterfall way http://www.flickr.com/photos/vizzzual-dot-com/2655969483/
  13. 13. The waterfall way Analysis • 2 weeks Design • 3 weeks Code • 4 weeks Test • 4 weeks Release • 14th week
  14. 14. The fall of waterfall Analysis • 2 weeks • 2 weeks Design • 3 weeks • 4 weeks Code • 4 weeks • 5 weeks Test • 4 weeks • 2 weeks Release • 14th week • 14th week
  15. 15. Testing can only indicate the quality http://www.flickr.com/photos/24560044@N08/5726488676/
  16. 16. But Feedback is Important
  17. 17. When to receive feedback? • Closest to the incident • Frequently • You get more time to act upon
  18. 18. Test Early Approach • Test as and when you complete small chunk of code (say a function – is it small?) • Integrate – Early, Small & Often – But involves cost
  19. 19. Nature of Business Environment http://www.flickr.com/photos/oldben/2301828397/
  20. 20. Mistaken Assumption http://www.flickr.com/photos/9465588@N05/3302103347/
  21. 21. The Solution Embrace Change
  22. 22. Automated Testing • Mitigates – Integration testing cost – Regression testing cost
  23. 23. Benefits • S - Savings through early integration • C - Cost of automating tests • ROI = S / C • (Small + Often) integration => more S
  24. 24. Still Problems !! http://www.flickr.com/photos/mosmancouncil/3361174929/
  25. 25. Waste • Unused Code • Lack of modularity
  26. 26. The Ultimate Solution • Write test code before production code
  27. 27. How Writing Tests Help? • Clarifies the acceptance criteria • Encourages to write loosely coupled components • Adds executable description of what code does • Regression suite
  28. 28. How Running Tests Help? • Detects errors (early) • Lets us know when we have done enough • Avoid unnecessary features
  29. 29. Test Driven Cycle 1. Write failing Tests 2. Write code pass tests 3. Refactor
  30. 30. TDD – Rule #1 No code will be written without a failing test
  31. 31. TDD – Rule #2 No more tests will be written Than sufficient to fail
  32. 32. TDD – Rule #3 No more code will be written than sufficient to pass failing tests
  33. 33. Demo
  34. 34. Feedback from tests Unit tests End-End testing AmountofFeedback Internal Quality Feedback External Quality Feedback White Box Black Box
  35. 35. http://www.flickr.com/photos/winning-information/2325865367/
  36. 36. http://www.flickr.com/photos/winning-information/2325865367/

×