1
Test Driven
Development (TDD)
Software Craftsmanship
2
@spinelli_edu
Software Craftsmanship
3
@spinelli_edu
We Are!!!
4
@spinelli_edu
Why Test?
5
➔ Quality
➔ Cost
➔ Laziness
@spinelli_edu
6
@spinelli_edu
The Importance of Testing
7
@spinelli_edu
Knight Capital Group's
In August 2012 Knight
Capital Group Inc., one of
America’s largest trading
firms, mistakenly sent out
more than four million
stock orders in less than an
hour.
The software bug caused
over $440 million in losses,
which is almost four times
what the company made in
2011.
NASA - Mariner 1
When US to send a
spacecraft to Venus. A
hyphen in coded computer
instructions in the data
editing program, resulted in
incorrect guidance signals
being sent to the spacecraft.
The cost for the rocket was
reportedly more than $18
million at the time.
Toyota Recall
Toyota ended up recalling
more than 9 million cars
worldwide in 2010, but it
wasn't because of a
mechanical issue. The cars
had a software bug that
caused a lag in the
anti-lock-brake system. Due
to increased incentive
campaigns, legal liabilities,
and marketing efforts, the
recalls were estimated to
cost Toyota as much as $3
billion.
Unit Test
8
➔ Fast
➔ Automatic
➔ Facilitates Change
➔ Simplifies Integration
@spinelli_edu
Test-Driven Development
9
➔ Focus on Test
➔ Code is Born Tested
➔ Simplicity
➔ Better Class Design Visibility
@spinelli_edu
RED - GREEN - REFACTOR
10
@spinelli_edu
Baby Steps
11
“Write The Simplest Code That Passes The Test”
return true;
@spinelli_edu
Feedback
12
➔ Cohesion
➔ Coupling
➔ Encapsulation
@spinelli_edu
Complex Problems
13
@spinelli_edu
Why developers don’t use TDD
14
➔ Management doesn’t allow us
➔ Not enough time to write tests
➔ My team disagrees whether we should
use TDD
➔ Return On Investment in TDD isn’t
proved
➔ Slow build process
➔ We tried but it didn’t work
➔ I don’t know all requirements upfront to
write all tests @spinelli_edu
Microsoft and IBM
Case study at Microsoft and
IBM and the results indicated
that the number of
four-product defects
decreased by 40-90% over
similar projects that did not
use TDD. However, the study
also showed TDD increased
the initial development time
by 15% to 35%.
Does TDD really help?
15
@spinelli_edu
More Tests
TDD increases code quality,
provides greater ease of
maintenance, and helps
produce 33% more testing
compared to traditional
approaches.
Programmers
The code had coverage
ranging from 92% to 98%. A
qualitative analysis showed
that 87.5% of programmers
believe that TDD facilitated
the understanding of the
requirements and 95.8%
believe that TDD reduced the
time spent debugging.
However, only 50% believe
that TDD helps to decrease
development time. About
quality, 92% believe that TDD
helps maintain a quality code.
When TDD doesn't Work
16
➔ Low Complexity
➔ Domain of Implementation
➔ TDD All Time
➔ 100% code coverage
➔ Test First vs TDD
@spinelli_edu
Books
17
@spinelli_edu
CREDITS
▪ http://manifesto.softwarecraftsmanship.org/
▪ https://crossbrowsertesting.com/blog/development/software-bug-cost/
▪ http://blog.celerity.com/the-true-cost-of-a-software-bug
▪ https://www.seguetech.com/the-benefits-of-unit-testing/
▪ https://technologyconversations.com/2013/12/24/test-driven-development-tdd-best-practices-u
sing-java-examples-2/
▪ http://philippe.bourgau.net/dont-stick-to-tdds-red-green-refactor-loop-to-the-letter/
▪ https://www.mauricioaniche.com/2010/11/cuidado-com-seus-baby-steps/
▪ http://www.extremeprogramming.org/rules/testfirst.html
▪ https://www.mauricioaniche.com/2010/04/tdd-realmente-ajuda/
▪ https://www.javacodegeeks.com/2018/02/developers-dont-use-tdd.html
▪ https://www.casadocodigo.com.br/products/livro-tdd
▪ https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530/ref=sr_1_1?ie=UT
F8&qid=1536630271&sr=8-1&keywords=kent+beck
18
@spinelli_edu
19
THANKS!
Any questions?
You can find me at:
▪ @spinelli_edu
▪ eduardosl.dev@gmail.com

Test Driven Development (TDD)

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
    Why Test? 5 ➔ Quality ➔Cost ➔ Laziness @spinelli_edu
  • 6.
  • 7.
    The Importance ofTesting 7 @spinelli_edu Knight Capital Group's In August 2012 Knight Capital Group Inc., one of America’s largest trading firms, mistakenly sent out more than four million stock orders in less than an hour. The software bug caused over $440 million in losses, which is almost four times what the company made in 2011. NASA - Mariner 1 When US to send a spacecraft to Venus. A hyphen in coded computer instructions in the data editing program, resulted in incorrect guidance signals being sent to the spacecraft. The cost for the rocket was reportedly more than $18 million at the time. Toyota Recall Toyota ended up recalling more than 9 million cars worldwide in 2010, but it wasn't because of a mechanical issue. The cars had a software bug that caused a lag in the anti-lock-brake system. Due to increased incentive campaigns, legal liabilities, and marketing efforts, the recalls were estimated to cost Toyota as much as $3 billion.
  • 8.
    Unit Test 8 ➔ Fast ➔Automatic ➔ Facilitates Change ➔ Simplifies Integration @spinelli_edu
  • 9.
    Test-Driven Development 9 ➔ Focuson Test ➔ Code is Born Tested ➔ Simplicity ➔ Better Class Design Visibility @spinelli_edu
  • 10.
    RED - GREEN- REFACTOR 10 @spinelli_edu
  • 11.
    Baby Steps 11 “Write TheSimplest Code That Passes The Test” return true; @spinelli_edu
  • 12.
    Feedback 12 ➔ Cohesion ➔ Coupling ➔Encapsulation @spinelli_edu
  • 13.
  • 14.
    Why developers don’tuse TDD 14 ➔ Management doesn’t allow us ➔ Not enough time to write tests ➔ My team disagrees whether we should use TDD ➔ Return On Investment in TDD isn’t proved ➔ Slow build process ➔ We tried but it didn’t work ➔ I don’t know all requirements upfront to write all tests @spinelli_edu
  • 15.
    Microsoft and IBM Casestudy at Microsoft and IBM and the results indicated that the number of four-product defects decreased by 40-90% over similar projects that did not use TDD. However, the study also showed TDD increased the initial development time by 15% to 35%. Does TDD really help? 15 @spinelli_edu More Tests TDD increases code quality, provides greater ease of maintenance, and helps produce 33% more testing compared to traditional approaches. Programmers The code had coverage ranging from 92% to 98%. A qualitative analysis showed that 87.5% of programmers believe that TDD facilitated the understanding of the requirements and 95.8% believe that TDD reduced the time spent debugging. However, only 50% believe that TDD helps to decrease development time. About quality, 92% believe that TDD helps maintain a quality code.
  • 16.
    When TDD doesn'tWork 16 ➔ Low Complexity ➔ Domain of Implementation ➔ TDD All Time ➔ 100% code coverage ➔ Test First vs TDD @spinelli_edu
  • 17.
  • 18.
    CREDITS ▪ http://manifesto.softwarecraftsmanship.org/ ▪ https://crossbrowsertesting.com/blog/development/software-bug-cost/ ▪http://blog.celerity.com/the-true-cost-of-a-software-bug ▪ https://www.seguetech.com/the-benefits-of-unit-testing/ ▪ https://technologyconversations.com/2013/12/24/test-driven-development-tdd-best-practices-u sing-java-examples-2/ ▪ http://philippe.bourgau.net/dont-stick-to-tdds-red-green-refactor-loop-to-the-letter/ ▪ https://www.mauricioaniche.com/2010/11/cuidado-com-seus-baby-steps/ ▪ http://www.extremeprogramming.org/rules/testfirst.html ▪ https://www.mauricioaniche.com/2010/04/tdd-realmente-ajuda/ ▪ https://www.javacodegeeks.com/2018/02/developers-dont-use-tdd.html ▪ https://www.casadocodigo.com.br/products/livro-tdd ▪ https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530/ref=sr_1_1?ie=UT F8&qid=1536630271&sr=8-1&keywords=kent+beck 18 @spinelli_edu
  • 19.
    19 THANKS! Any questions? You canfind me at: ▪ @spinelli_edu ▪ eduardosl.dev@gmail.com