Test Driven Development
discipline
we adopt, commit to and follow it
three laws
You are not allowed to write any production code unless it is to make a failing unit test pass
1st law
You are not allowed to write any more of a unit test than is sufficient to fail; and not compiling is failure
2nd law
You are not allowed to write any more production code than is sufficient to pass the one failing unit test
3rd law
cycle of tdd
testing pyramid
http://willhamill.com/assets/images/20130812_testing_ice_cream_cone.png
The ice-cream cone
recommended resources
Authors, speakers
- Kent Beck
- Robert C. Martin
- Michael Feathers
- Martin Fowler
Books
Kent Beck: TDD by example
Robert C. Martin: Clean Code series
Michael Feathers: Working Effectively with Legacy Code
Martin Fowler: Refactoring
Nat Pryce, Steve Freeman: Growing OO Software Guided by Tests
Talks
in practice
write a unit test
1.
it does not compile!
write a line of prod. code
2.
it compiles! back to the test!
how long
does it take?
15 sec?
stuck in the loop
line by line
slow? tedious? boring?
can be, but
every single line
can be tested
in a matter of seconds!
100K?
instant feedback
100% confidence
0% debugging
power of tdd
a unit test
executable
repeatable
documentation
writing tests after
is it fun? :(
following the 3 laws
write the tests first
cannot write
hard-to-test code
decoupling
as side effect
reusable components
as a plus
and it's fun! :)
TDD workshop
By Marton Hipszki
TDD workshop
- 802