Introduction to
Test Driven Development
Sivasubramaniam Arunachalam
Mar 29, 2014
@sivaa_in
http://barcampbangalore.org/bcb...
It’s me!
It’s about you!
#barcampblr
#tdd
Just Before We Get
Started
How many of you are
• Developers
• Testers/Quality
• Manual
• Automated
Manual/Automated Developers?
> 100K
> 5
Waste of time
No
Opportunity
Test
Driven Development
TDD is NOT a
Testing Strategy
TDD is a
Design Strategy
TDD is NOT for
Testers
TDD is for
Developers
(1) – (2) – (3)
(1) – (2) – (3)
Others
Code
(1) – (2) – (3)
Legacy
Systems
(1) – (2) – (3)
Change in
Architecture
How to Start?
How I have
Started?
The Correct way
Refactoring?
• Removing duplication
• Make the logic simpler
• Make the code easier to read
TDD Components
• Unit Tests
• Functional Tests
• Integration Tests
Unit Tests
Unit Tests
Best Practices
• Focus one Class/Method
• Keep it under 10 seconds
• Execute 100 tests/second
• Runs only on me...
Integration Tests
Functional Tests
Are you ready now?
Everyone likes to
have tests
but
Few people like
writing them.
Only way to test
Interfaces & Design
Immediate
Confirmation
Helps to re-think what
Needs to be Coded
Acts as a
Low Level Spec
Less Rework
Regression
due to refactoring
This is the only way to find it
No More
Dead Code
Less code = Less bugs
Unit Tests
might act as a
Documentation
Less
Debugging
Lets calculate the Cost
2 x $25 = $50
N x $M = $5K
will become
Faster
Development
By Products
• Forces you to write small classes
(focused on one thing.)
• Helps create loosely coupled code
• Measure impl...
How Much is
enough?
Can I test
Getters and Setters?
Can I test
Third-Party Libraries?
(How)
Can I test
Private Methods?
(How)
Can I test
User Interfaces?
Be a Cool dude
and exclude
Where to focus
More and Less?
Mock Objects
Scaling
When do we
FAIL?
Why businesses don’t
like TDD?
How to start TDD for
existing applications?
Potential
Challenges
Applicable for
Startups?
Is it really
worth it?
http://www.ipd.uni-karlsruhe.de/Tichy/uploads/publikationen/35/edser03.pdf
http://programmers.stackexchange.com/questions/206355/the-relative-cost-efficiency-of-acceptance-test-driven-development
Someone is using it?
http://agilepainrelief.com/notesfromatooluser/2008/11/misconceptions-with-test-driven-development.html
Lets see some
(test) code
Dis-advantages
(You will lose)
• Ability to say you are "done" before testing all your code.
• Opportunity to learn throug...
TFD vs TDD
Code without tests is
broken by design.
- Jacob Kaplan-Moss
Debugging is twice as hard as writing
the code in the first place.
- Brian Kernighan
Debugging is twice as hard as writing
the code in the first place.
Therefore, if you write the code as cleverly as possibl...
Thank You!
siva@sivaa.in
bit.ly/sivasubramaniambit.ly/sivaa_in
References
https://www.youtube.com/watch?v=DodJQyHsmHI
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Introduction to Test Driven Development
Upcoming SlideShare
Loading in …5
×

Introduction to Test Driven Development

1,247
-1

Published on

Presented at Barcamp Bangalore Spring 2014.

http://barcampbangalore.org/bcb/bcb15/introduction-to-test-driven-development-tdd

Published in: Technology
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
1,247
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
7
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to Test Driven Development

  1. 1. Introduction to Test Driven Development Sivasubramaniam Arunachalam Mar 29, 2014 @sivaa_in http://barcampbangalore.org/bcb/bcb15/introduction-to-test-driven-development-tdd
  2. 2. It’s me!
  3. 3. It’s about you! #barcampblr #tdd
  4. 4. Just Before We Get Started
  5. 5. How many of you are • Developers • Testers/Quality • Manual • Automated Manual/Automated Developers?
  6. 6. > 100K
  7. 7. > 5
  8. 8. Waste of time
  9. 9. No Opportunity
  10. 10. Test Driven Development
  11. 11. TDD is NOT a Testing Strategy
  12. 12. TDD is a Design Strategy
  13. 13. TDD is NOT for Testers
  14. 14. TDD is for Developers
  15. 15. (1) – (2) – (3)
  16. 16. (1) – (2) – (3) Others Code
  17. 17. (1) – (2) – (3) Legacy Systems
  18. 18. (1) – (2) – (3) Change in Architecture
  19. 19. How to Start?
  20. 20. How I have Started?
  21. 21. The Correct way
  22. 22. Refactoring? • Removing duplication • Make the logic simpler • Make the code easier to read
  23. 23. TDD Components • Unit Tests • Functional Tests • Integration Tests
  24. 24. Unit Tests
  25. 25. Unit Tests Best Practices • Focus one Class/Method • Keep it under 10 seconds • Execute 100 tests/second • Runs only on memory
  26. 26. Integration Tests
  27. 27. Functional Tests
  28. 28. Are you ready now?
  29. 29. Everyone likes to have tests but Few people like writing them.
  30. 30. Only way to test Interfaces & Design
  31. 31. Immediate Confirmation
  32. 32. Helps to re-think what Needs to be Coded
  33. 33. Acts as a Low Level Spec
  34. 34. Less Rework
  35. 35. Regression due to refactoring This is the only way to find it
  36. 36. No More Dead Code Less code = Less bugs
  37. 37. Unit Tests might act as a Documentation
  38. 38. Less Debugging
  39. 39. Lets calculate the Cost 2 x $25 = $50 N x $M = $5K will become
  40. 40. Faster Development
  41. 41. By Products • Forces you to write small classes (focused on one thing.) • Helps create loosely coupled code • Measure implementation progress
  42. 42. How Much is enough?
  43. 43. Can I test Getters and Setters?
  44. 44. Can I test Third-Party Libraries?
  45. 45. (How) Can I test Private Methods?
  46. 46. (How) Can I test User Interfaces?
  47. 47. Be a Cool dude and exclude
  48. 48. Where to focus More and Less?
  49. 49. Mock Objects
  50. 50. Scaling
  51. 51. When do we FAIL?
  52. 52. Why businesses don’t like TDD?
  53. 53. How to start TDD for existing applications?
  54. 54. Potential Challenges
  55. 55. Applicable for Startups?
  56. 56. Is it really worth it?
  57. 57. http://www.ipd.uni-karlsruhe.de/Tichy/uploads/publikationen/35/edser03.pdf
  58. 58. http://programmers.stackexchange.com/questions/206355/the-relative-cost-efficiency-of-acceptance-test-driven-development
  59. 59. Someone is using it? http://agilepainrelief.com/notesfromatooluser/2008/11/misconceptions-with-test-driven-development.html
  60. 60. Lets see some (test) code
  61. 61. Dis-advantages (You will lose) • Ability to say you are "done" before testing all your code. • Opportunity to learn through debugging. • Flexibility to ship code that you aren't sure of. • Freedom to tightly couple your modules. • Option to skip writing low level design documentation. • Stability that comes with code that everyone is afraid to change. • Capability to write hundreds or thousands of lines of code before running it.
  62. 62. TFD vs TDD
  63. 63. Code without tests is broken by design. - Jacob Kaplan-Moss
  64. 64. Debugging is twice as hard as writing the code in the first place. - Brian Kernighan
  65. 65. Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. - Brian Kernighan
  66. 66. Thank You! siva@sivaa.in bit.ly/sivasubramaniambit.ly/sivaa_in
  67. 67. References https://www.youtube.com/watch?v=DodJQyHsmHI
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×