Introduction to TDD
Alvaro García - @alvarobiz
A G Maur Idea
2015-03-15
v 1.2
Who am i
@alvarobiz - #introTDD
- I craft software
-
Currently, one big client
- and some small ones
- I tweet at @alvarobiz
- I blog at alvarogarcia7.github.io
- Came here to learn from you
This is me crafting
@alvarobiz - #introTDD
More like...
@alvarobiz - #introTDD
Who am i (II)
@alvarobiz - #introTDD
-
Invited to organize:
- Software Craftsmanship Barcelona meetup
- Software Craftsmanship Barcelona 2014
- Dev Practices & Craftsmanship Track at the CAS 2014
What is this tdd thing
@alvarobiz - #introTDD
?
Wasn't tdd dead?
@alvarobiz - #introTDD
Wait what??
@alvarobiz - #introTDD
well maybe not...
@alvarobiz - #introTDD
- The right tool for the right job
- It works for others and for me
-
is there some interest?
- that's why you came :)
a tdd cycle
@alvarobiz - #introTDD
Have you understood?
@alvarobiz - #introTDD
Nope
let me implement that
@alvarobiz - #introTDD
@alvarobiz - #introTDD
Have you understood?
@alvarobiz - #introTDD
Yep
Refactor
@alvarobiz - #introTDD
@alvarobiz - #introTDD
Have you understood?
@alvarobiz - #introTDD
Yep
@alvarobiz - #introTDD
Questions?
What it really is about
@alvarobiz - #introTDD
- Clean code that works (Ron Jeffries)
- Predictable way to develop
More in depth
@alvarobiz - #introTDD
Red: implement a failing test
Green: implement a passing test
Refactor: change how but not what
Compare that to test last
@alvarobiz - #introTDD
Implement a feature
Refactor said feature (!)
Create a test for the feature
The test is not passing
@alvarobiz - #introTDD
Debug
Ahh, damn
Fix
Finally :)
Compare that to test last (II)
TDD to explain tdd
@alvarobiz - #introTDD
Thanks to Stanley Milgram for the social experiment :)
Show me the code
@alvarobiz - #introTDD
Specifications
@alvarobiz - #introTDD
As a meetup organizer,
I want a list
That can store strings
So I can store the attendants' names
(Java) API
@alvarobiz - #introTDD
- Constructor: new MyStringList()
-
Methods:
- void add(String)
- boolean isEmpty()
- boolean contains(String)
(please don't use any java.util.* collection :) )
Final code
@alvarobiz - #introTDD
here:
That's all folks
@alvarobiz - #introTDD
Questions?
@alvarobiz - #introTDD
Feedback ?
@alvarobiz - #introTDD
Raise your hands when:
Thanks
@alvarobiz - #introTDD
tweet about it: @alvarobiz :)
Mocks, stubs, fakes
AND OTHER TEST DOUBES
@alvarobiz - #introTDD
Mock
@alvarobiz - #introTDD
STUB
@alvarobiz - #introTDD
FAKE
@alvarobiz - #introTDD
DUMMY
@alvarobiz - #introTDD
SPY
@alvarobiz - #introTDD
That's all folks
@alvarobiz - #introTDD
@alvarobiz - #introTDD
NOW IT IS YOUR TURN
@alvarobiz - #introTDD
NOW IT IS MY TURN
Introduction to TDD
By alvarobiz
Introduction to TDD
- 525