TDD
That Feels Great
Toby Ho @airportyh tobyho.com
Got 'Scripts? Test'em!
Quick start: How to TDD
- Write a test
- See it fail
- Write some code
- See it pass
- Refactor (optional)
- Repeat
Why TDD?
Why TDD?
- Fewer defects
- Protect against regression
- Well designed API
- Re-use tests as specs
Where is the Pain?
- Fix a bug. Create another.
- Play pong with the QA person.
- Refactor something, break something.
- Getting stuck trying to track hard-to-find bugs.
But I Heard TDD is Painful?
Sounds like having fun at the dentist
How To TDD w/o the pain?
Good Feedback!
Good Feedback
- Fast
- Frequent
- Reliable
How To Get Good Feedback?
- Have good workflow
- Have tests finish fast
- Take small steps
Workflow Tips
- Don't use slow software
- Don't run software you don't need
- Autorun your tests on save
- Don't switch windows, tile'em
- Typing fast helps. Practice.
Having Tests Finish Fast
- Rule of thumb: < 1 second
- Favor fast tests (unit tests) to slow tests (integration tests)
- Too many tests? Break them up.
- Run subset of tests
- Break up into subprojects
Take Small Steps
Small Step Test Patterns
- Child tests
- Fake it 'til you make it
- One to many
- Change one thing at a time
- Back up and refactor
Live Code!
A demonstration of
small step test patterns.
Thank You!
How to do TDD
- Write a test
- See it fail
- Write some code
- See it pass
- Refactor (optional)
- Start again at 1
TDD That Feels Great
By airportyh
TDD That Feels Great
- 710